Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Confusing validwhen rule

 
Velika Srbija
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
<var-name>test</var-name>
<var-value>((sendNewsletter == null) or (*this* != null))</var-value>
</var>
</field>

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.?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic