• 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.?
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!