• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

logic:equal - AND / OR?

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to do a OR with this tag e.g.
<logic:equal name="titleForm" property="action" scope="request" value="Edit||Create">
TIA
 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. The value attribute is a constant. If the value can be converted to a double or a long, numeric comparison will be performed, otherwise String comparison will be performed.
Struts Logig Tags
 
Johann Evans
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thx!
What is the common workaround / solution if one should like to evaluate for two or more values like in my problem scenario?
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Johann Evans:
Thx!
What is the common workaround / solution if one should like to evaluate for two or more values like in my problem scenario?


There are a couple of ways you can do this. It can get kind of cumbersome but here are some options:
1) AND - use nested logic:equals tags. Place the code you want to execute inside the innermost logic:equal tag. It will only execute if both conditions are true.
2a) OR - check the condition twice. Obviously this isn't an optimal solution but will do in a pinch.
2b) OR - evaluate the condition and set a variable based on the outcome (for example "true" if the OR condition is true, "false" if it is false). Evaluate that variable with your logic:equals tag.
3) Use the JSTL. I'm not too familiar with it, but I believe they have a more robust set of conditional tags. The Struts gurus are even recommending you use JSTL tags when appropriate, so you don't have to feel like you're doing something taboo by going this route.
HTH
 
Ranch Hand
Posts: 5399
1
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jason Menard:

2a) OR - check the condition twice. Obviously this isn't an optimal solution but will do in a pinch.
2b) OR - evaluate the condition and set a variable based on the outcome (for example "true" if the OR condition is true, "false" if it is false). Evaluate that variable with your logic:equals tag.
HTH


Still I am not very clear how to implement OR in struts ??
any small example would help, let us say
if(i > 4 || j < 10) {
// do something
}
How to implement this in struts with logic tags ??
TIA
 
R K Singh
Ranch Hand
Posts: 5399
1
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I checked JSTL tutorial but could not found helpful for OR implementation.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic