ognl

How can use if tag in Struts 2?

五迷三道 提交于 2019-12-01 11:59:17
问题 I am really new to Struts2. I have the below Struts2 tag, I need to check if property value="#attr.row.Commentaire is not empty and if it's not, display a small icon where the user can click it and consult the contents of the property value="#attr.row.Commentaire . How can I use the if tag of Struts2 efficiently to do that? <display:column title="Commentaire" sortable="true" sortProperty="Commentaire" class="alerte_td_commentaire"> <s:property value="#attr.row.Commentaire"/> 回答1: Use the

Parameter Passing for statically included page in Struts 2

三世轮回 提交于 2019-12-01 11:59:12
I have a parent file where my JSP is statically included. <%@include file="test.jsp" %> In the included file I want to access the variable of parent JSP using Struts2 tag. Please let me know if it is possible or should I go for dynamic include. You can't access the variable but you can access the variable from the the value stack using OGNL. See OGNL Basics to learn more about variables in Struts and how to use them. Besides the examples and descriptions given above, there are a few major changes in the EL since WebWork 1.x. The biggest one is that properties are no longer accessed with a

Parameter Passing for statically included page in Struts 2

大憨熊 提交于 2019-12-01 11:40:20
问题 I have a parent file where my JSP is statically included. <%@include file="test.jsp" %> In the included file I want to access the variable of parent JSP using Struts2 tag. Please let me know if it is possible or should I go for dynamic include. 回答1: You can't access the variable but you can access the variable from the the value stack using OGNL. See OGNL Basics to learn more about variables in Struts and how to use them. Besides the examples and descriptions given above, there are a few

Numbers not formatted properly in Struts 2

≡放荡痞女 提交于 2019-12-01 11:07:39
问题 I am using following syntax to display a value in a proper number format, e.g. 1,250.00 . <s:property value="%{getText('{0,number,#,##0.00}',#plan.amount)}" /> However, it is not working. The plan is an object with a property amount. 回答1: If the value is printed like 1250.00 then it's not formatted properly. The method getText() has many overloaded methods and which method is used is determined by the parameter's types and count. To pass arguments to the getText() method you can use OGNL list

Struts2 devMode Exception when using “key” attribute in submit tag

╄→гoц情女王★ 提交于 2019-12-01 11:06:04
问题 I'm using Struts2 with devMode turned on to catch as many warnings and errors as possible. Now I got across with some SEVERE notification that is only notified in devMode. I'm using the submit tag and I include the key attribute to get the button text "Entrar" from a property called global.BOTON_LOGIN . The button is part of a form that calls an action mapped to the class actions.LoginAction : <s:submit key="global.BOTON_LOGIN" type="button" /> The text of the button displays correctly and

Submitting form's data to a java Set

送分小仙女□ 提交于 2019-12-01 11:02:46
Is it possible to submit a form's data to a java Set in an action of Struts2? Action code: class TestAction extends ActionSupport{ private Set<Integer> mySet = new LinkedHashSet<Integer>(); public TestAction(){ } public String test(){ someMethod(mySet); } ... Getters/Setters ... } Form code: <form action="test.action" > <input name="mySet[0]" /> <input name="mySet[1]" /> <input name="mySet[2]" /> <submit /> </form> The Set is just a collection, and Struts2 has support for any type of collections internally. But for this type of collection you can't use indexes in your OGNL expressions. Try

configure request param for action to be assigned to fields of bean

妖精的绣舞 提交于 2019-12-01 10:45:59
I am using www.datatables.net . JS framework to show data in tables. It has server mode and it sends a lot of params during this mode. Example: sortColumn , sortType(asc,desc) , filter values, pagenum , itemsonpage and so on. So i handle it in action. i assign to each request param field in action and it work fine. But now i have several table. So i have to make different actions but request params same and there are a lots of them. It is not a good idea to copy paste code from one action to another. So i did implement a DatatableParamBean which contain all params needed to work properly.

Generate name and value attribute dynamically in Struts 2

試著忘記壹切 提交于 2019-12-01 10:41:45
I am migrating the code from Struts1 to Struts2 Struts1 code <input type="text" value="<c:out value="${serviceVO.notifList}"/>" name="ServicesNotifList-<c:out value="${serviceVO.globalId}"/>#<c:out value="${serviceVO.id}"/>" size="50" maxlength="1000"/> in Struts2 I tried but not working <c:set var="notifListTemp" value="ServicesNotifList-"></c:set> <c:set var="notifListTemp1" >${notifListTemp}${serviceVO.globalId}</c:set> <c:set var="notifListTemp2" value="#"></c:set> <c:set var="notifListTemp3" >${notifListTemp1}${notifListTemp2}${serviceVO.id}</c:set> <s:textfield theme="simple" value="$

How to add two submit buttons on one form in Struts 2

跟風遠走 提交于 2019-12-01 10:23:57
问题 I'm developing an application using Struts2. My application is for online shopping. My task is updating and removing the shopping cart item. I have a JSP page and it has 4 text fields. I need to submit these text field's data to the Modify action. Updating and removing submit buttons are in same page, same form. How do I determine which is the button I've clicked on JSP form? My form is: <s:form action="ModifyCart"> <s:textfield readonly="true" name="shoppingCart.item.id" label="Item Code"

<s:select> with dynamic list name

孤街醉人 提交于 2019-12-01 09:08:51
I want to iterate over a list of strings containing names for <s:select> list source, but the HTML output is not as expected : it's the name of the list that is display, not the content . My Action code: public class DescriptionTabArchiveAction extends ActionSupport { private List<String> vegetables = new ArrayList<String>(); private List<String> devices = new ArrayList<String>(); // contain "vegetables" and "devices". private List<String> selectList = new ArrayList<String>(); @Action("multipleSelect") public String multipleSelect() { vegetables.add("tomato"); vegetables.add("potato"); devices