• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

if tag in struts 2

 
rahulJ james
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a scenario where I need to validate the date. I validate the date using Calendar and set the current date. I should not show few values when the date is 4 and 5(Wednesday and Thursday) but it doesnt work with my piece of code.. It works only for 4 and not for 5 . I doubt by or condition. Anyone advise me on the correct usage of operators

<s:if test='date== 4 || date == 5 '>

Advise please
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the date a Date object? If so, comparing it to a numerical literal won't work.
 
rahulJ james
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I forgot to mention, I use that as an int object.

objCalendar.get(Calendar.DAY_OF_WEEK) will return the integer and which is what I am comparing with
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try wrapping it in the OGNL escape: "%{date == 4 || date == 5}"
 
rahulJ james
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works!!! Thanks a lot
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic