This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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
It is sorta covered in the JavaRanch Style Guide.
subject: Struts ValidWhen validation
Similar Threads
Struts Validation Problem
Limits of Validator Framework
how to design this JSP. need ur suggestion
problem using validwhen and radio button
Struts: validations using 'validwhen' in validation.xml