This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Struts and the fly likes Help with validwhen rule Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Help with validwhen rule" Watch "Help with validwhen rule" New topic

Help with validwhen rule

Jeremy Stoneburner

Joined: Jul 11, 2005
Posts: 3
I'm curently working on a project that is being implemented using struts 1.2.4 and tomcat 4.1.31. I need to be able to validate a field using the validwhen rule, but I can't seem to get it to work. Here is the code from the validation.xml I'm trying to use.

<field property="minorityOth" depends="validwhen">
<arg0 key="" />
<var-value>(((*this* == null) and (minority != "Other")) or (*this* != null) and (minority == "Other"))</var-value>

minority is the name of a set of Radio buttons with one of the values being "Other" and minorityOth is a text field. The form is supposed to validate the text field if the user selects the "Other" radio button and enters something into the text field, or if the user selects a different radio button and leaves the text field blank. The problem I'm having is that the validation doesn't seem to be getting applied. Regardless of what combinations I've tried, I can't get an error message out of it. Anyone have any advice?
Usera User

Joined: Jul 13, 2005
Posts: 21
I also have the same problem, validwhen seems not work. I am using struts 1.2.7 and validator 1.1.3. I view the generated web page source code and find that no javascript function has been generated for the validwhen logic. Has any people known how to solve ? Thanks
I agree. Here's the link:
subject: Help with validwhen rule
It's not a secret anymore!