File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes achieving or condition with logic:equal Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "achieving or condition with logic:equal" Watch "achieving or condition with logic:equal" New topic

achieving or condition with logic:equal

Srinivas Rao

Joined: Aug 05, 2004
Posts: 14
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

Joined: Sep 06, 2005
Posts: 60
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>
I agree. Here's the link:
subject: achieving or condition with logic:equal
It's not a secret anymore!