Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

validwhen - struts validation  RSS feed

Gayatri Ganesh
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I need to validate a field called age only when a boolean isAge is true, ie age is a required field only when boolean isAge is true.
And also age should be an integer only. I

In my validation.xml I have :

<form name="/a/b/c">
<field property="age" depends="validwhen,required,integer">
<arg0 key="errors.invalid"/>
<var-value>((isAge == 'true') and (*this* == null))</var-value>
<msg key="error.age.integer" name="integer"/>

But I always get the error message, even if I enetered a valid age.
Can anyone please tell me what is wrong ?

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!