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

validwhen and its use?

 
Golla Vensiri
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While using vaildwhen in the following example picked up from the Apache site.

<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 there a way to have multiple test conditions. Meaning can we do this:-

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

</field>

It doesn't seem to work. Do we have any other way to accomplish the same.

Thanks.
 
alan do
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you need to write your multiple conditions in the same test.

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

</field>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic