Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

achieving or condition with logic:equal

 
Srinivas Rao
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to check for 'OR' condition in Struts. For example, if the status is 1 or 2, I have to show a bunch of code. So far I am using 2 blocks of logic:equal and copying the whole bunch of code. The problem with this approach is if I want to check many 'OR' conditions, difficult to maintain.

If I have to check many 'OR' conditions, I am doing all these checks in Action class and setting the result to another form variable and comparing these new variable in JSP. But this leads to additional(unnecessary) properties in the Form bean.

What is the best approach to achieve the above condition.
 
Ergin Er
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you can have 2 diiferent values for an attribute u can use this one I think.
<logic:equal name="FormBean" property="Attribute" value="${valuex || valuey}">

If u want to do a compare on 2 attributes than I would suggest to use <c:if>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic