File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes logic:equal compare two  values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "logic:equal compare two  values" Watch "logic:equal compare two  values" New topic
Author

logic:equal compare two values

Gayatri Sinha
Ranch Hand

Joined: Feb 13, 2006
Posts: 34
HI,

Using the logic:equal I can compare one bean with one value only,
<logic:equal id="beanvalue" value="5">

can I compare the bean to two values

like
(beanvalue=="5" || beanvalue=="6")

I want to use struts tags only..

Thanks
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Unfortunately, <logic:equal> does not have the capability to do "and/or" comparisons. If you want to do an "and" comparison, you can nest one inside the other, but for an "or" comparison your only options are to use a scriptlet or to use JSTL.


Merrill
Consultant, Sima Solutions
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
In many cases the JSTL is a better choice than the Struts Logic tags. This is one of those cases. In fact if you look at the online docs for the Logic tag library you will see this note at the very top of the page.

Note: - Many of the features in this taglib are also available in the JavaServer Pages Standard Tag Library (JSTL) . The Struts team encourages the use of the standard tags over the Struts specific tags when possible.


Edited to add this: One thing you can do though is to move the logic into your Form...something like this:

In your Action Form:
public boolean getShouldDisplaySection()
{
return (this.beanvalue.equals("5") || this.beanvalue.equals("6"))
}

In your JSP:
<logic:equal name="myForm" property="shouldDisplaySection" value="true">


- Brent
[ March 02, 2006: Message edited by: Brent Sterling ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: logic:equal compare two values