• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

logic:equal compare two values

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic