wood burning stoves 2.0*
The moose likes Struts and the fly likes Confusing validwhen rule Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Confusing validwhen rule" Watch "Confusing validwhen rule" New topic

Confusing validwhen rule

Velika Srbija
Ranch Hand

Joined: Jan 15, 2002
Posts: 172
There is an excerpt from the Struts Validator Guide:
As an example of how this would work, consider a form with fields sendNewsletter and emailAddress. The emailAddress field is only required if the sendNewsletter field is not null. You could code this using the validwhen rule as:

<field property="emailAddress" depends="validwhen">
<arg0 key="userinfo.emailAddress.label"/>
<var-value>((sendNewsletter == null) or (*this* != null))</var-value>

Which reads as: this field is valid if sendNewsletter is null or the field value is not null.

Is this condition OK?
Any moe detailed explanation.?
It is sorta covered in the JavaRanch Style Guide.
subject: Confusing validwhen rule
Similar Threads
validwhen returns required error messge
Limits of Validator Framework
How to Bypass struts validation
validwhen and its use?
struts 1.2.7 validation using validwhen