ognl


How to add a condition in Struts iterator tag?

耗尽温柔 提交于 2020-01-15 13:33:45
问题 I want to highlight a row when the value of rating is less than or equal to 2 . I am not able to use the <s:if> to get my result. Please tell me how to put condition in my JSP page. <table> <s:iterator value="fb" status="abc"> <s:if test="#abc.rating==2"> <td style="background: #CCCCCC"> </s:if> <tr> <td><s:property value="cid"/></td> <td><s:property value="cname"/></td> <td><s:property value="rating"/></td> <td><s:property value="likes"/></td> <td><s:property value="dislikes"/></td> <td><s

How do I convert a JSP variable to a Struts2 variable?

故事扮演 提交于 2020-01-15 05:26:49
问题 How do I convert a JSP variable to a Struts2 variable? I've tried the following: <%=scoredDocument%> <s:push value="scoredDocument"/> <s:push value="#scoredDocument"/> <s:push value="%{scoredDocument}"/> <s:push value="${scoredDocument}"/> <s:push value="#page.scoredDocument"/> <s:push value="%{#page.scoredDocument}"/> <display:column title="Study Code" sortable="true"> <s:property value="id"/> The most frequent error is Caused by: tag 'push', field 'value': You must specify a value to push

Strange OGNL behaviour when using #this in s:select

拟墨画扇 提交于 2020-01-14 14:26:48
问题 Consider the following where availableExclusions is an array of Date objects. <s:select listValue="(new java.text.SimpleDateFormat('MM/dd/yyyy')).format(new java.util.Date(#this[0].time))" size="25" id="inputExclusionDates" name="available" list="availableExclusions" multiple="true" cssClass="multi-select" /> I created the above in response to this question How would I format a list of dates within a struts 2 select tag? (and I also recommended that the other solution may be the better way to

How to include HTML in OGNL expression language in Struts 2

雨燕双飞 提交于 2020-01-14 02:48:21
问题 I am working on struts 2. I was doing a projection of a collection in my JSP page using OGNL expression language. I have 1 list based collection in my action class, that I am accessing on JSP page like this: <s:iterator value="lsEmp.{name + '<b>---</b>' + address}"> //lsEmp is a list based collection <s:property /><br> </s:iterator> I want the output like this: rajiv --- N.Delhi nakul --- Mumbai vinay --- Banglore //"---" being bold . But my <b></b> tag in <s:iterator value=""> is not getting

Prevent getText() evaluating EL expressions

血红的双手。 提交于 2020-01-14 01:36:23
问题 In Struts2 backend, I have an action class instance variable, eg: keyName . A dynamic key returned to view(JSP). This keyName variable is set using a request parameter using POST method. Depending on the request parameter value, the keyName will vary. In JSP, I am using <s:property value="getText(keyName)" /> to show the label corresponding to the key given by keyName variable. When I send an EL expression for example ${90-40} to keyName this expression is being evaluated and resulting in

How to test bean property in Struts 2?

雨燕双飞 提交于 2020-01-13 19:36:50
问题 I have a class like this: public class Foo { public boolean isValid() { return false; } } In my JSP file I want to use the isValid method in a test condition: <s:bean name="com.Foo" var="bar"></s:bean> <s:if test="%{bar.valid == false}"> <p>hello</p> </s:if> but it doesn't work. What did I do wrong? 回答1: Context variables are referenced by # , but you've used a name bar without number sign. <s:if test="%{#bar.valid == false}"> <p>hello</p> </s:if> Look at the Variable References of the OGNL

How to test bean property in Struts 2?

こ雲淡風輕ζ 提交于 2020-01-13 19:35:35
问题 I have a class like this: public class Foo { public boolean isValid() { return false; } } In my JSP file I want to use the isValid method in a test condition: <s:bean name="com.Foo" var="bar"></s:bean> <s:if test="%{bar.valid == false}"> <p>hello</p> </s:if> but it doesn't work. What did I do wrong? 回答1: Context variables are referenced by # , but you've used a name bar without number sign. <s:if test="%{#bar.valid == false}"> <p>hello</p> </s:if> Look at the Variable References of the OGNL

To access the index value of struts iterator in scriptlet array index

三世轮回 提交于 2020-01-13 09:55:07
问题 I am a newbie in web development. Using Struts2, I have a comma separated String of my images captions. While iterating the images to render on JSP I need to display caption along with specific images and could not get any specific tag to split caption String over delimiter and to access specific caption. I am trying the below code and don't know what to use in place of something to get the current iteration index in iterator. <s:iterator value="images" status="incr"> <%= ((String)request

“Select” not populated from List<String> in struts

混江龙づ霸主 提交于 2020-01-11 10:13:13
问题 I have the following sources: struts.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.enable.DynamicMethodInvocation" value="true" /> <constant name="struts.devMode" value="true" /> <constant name="struts.custom.i18n.resources" value="ApplicationResources" /> <package name="vislabWebShop" extends="struts-default"> <action name=

“Select” not populated from List<String> in struts

試著忘記壹切 提交于 2020-01-11 10:11:59
问题 I have the following sources: struts.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.enable.DynamicMethodInvocation" value="true" /> <constant name="struts.devMode" value="true" /> <constant name="struts.custom.i18n.resources" value="ApplicationResources" /> <package name="vislabWebShop" extends="struts-default"> <action name=

工具导航Map