wood burning stoves 2.0*
The moose likes Struts and the fly likes if tag in struts 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "if tag in struts 2" Watch "if tag in struts 2" New topic
Author

if tag in struts 2

rahulJ james
Ranch Hand

Joined: Oct 03, 2008
Posts: 123
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

Joined: Sep 29, 2008
Posts: 12617

Is the date a Date object? If so, comparing it to a numerical literal won't work.
rahulJ james
Ranch Hand

Joined: Oct 03, 2008
Posts: 123
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

Joined: Sep 29, 2008
Posts: 12617

Try wrapping it in the OGNL escape: "%{date == 4 || date == 5}"
rahulJ james
Ranch Hand

Joined: Oct 03, 2008
Posts: 123
It works!!! Thanks a lot
 
 
subject: if tag in struts 2
 
Similar Threads
Doubt in field validation using struts
CTS or Satyam
validations using strings
Doubt in this expression i-- %5?
howto validate whether the input is date string ?