It's not a secret anymore!
The moose likes Struts and the fly likes Struts ValidWhen validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts ValidWhen validation" Watch "Struts ValidWhen validation" New topic

Struts ValidWhen validation

Hiren Pathak

Joined: Mar 24, 2003
Posts: 21
Hello All,
I am using Struts Validation framework and I want to use strust validwhen condition.

I have beginYear and endYear. The difference between beginYear and endYear should be one. So i did something like this.

But it doesnt work. Does anybody have any idea how can I achieve this ???

Thnx in advance

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I must confess to being a little disappointed in the validWhen validation rule. What you're allowed to put in the test expression is very limited, and does not include addition or subtraction.

I'd suggest writing your own custom validation rule for this.

Consultant, Sima Solutions
Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456
what came across my mind when i read you post (it has nothing to do with you question though, but might be worth considering)

are you sure you need _this_ validation? if i had the user to enter two years, and if one needs to be the following year of the other, i'd reduce user input to just one field


is that an option for you special case?

Manuel Jordan
Ranch Hand

Joined: Sep 29, 2006
Posts: 131
Hello guys

you can personalize your own type of exceptions (i.e. MyDateException) and could be throw from a BusinessObject (using the simple methods of class Date) (to compare 2 dates)

is only my suggestion

[ October 09, 2006: Message edited by: Manuel Jordan ]

kill your pride, share your knowledge with all
subject: Struts ValidWhen validation
jQuery in Action, 3rd edition