Struts Validator - Validwhen and Map backed forms



Hi,

Regarding the Struts validator framework:-
Does anybody know whether its possible to use the validwhen validator
determine whether a field is required based on the value of a map
backed form property:-

i.e:-
This validator field element should make the property
"demographic(fav_color)" mandatory if the map backed property
"mandatory(fav_color)" is not 'false'.

<field property="demographic(fav_color)" depends="validwhen">
<msg name="validwhen" key="errors.required" />
<arg name="validwhen" key="form.demographic.favColor" />
<var>
<var-name>test</var-name>
<var-value>((mandatory(fav_color) != "false") or (*this* != null))</
var-value>
</var>
</field>

However this gives me an exception when run. The exception is as
follows:-
"ValidWhen Error for field ' demographic(fav_color)' - line 1:3:
unexpected token: mandatory"

I'm assuming that using validwhen with map backed properties is not
possible and is a recipe for struts inspired developer rage! Please
tell me I'm wrong :)

thanks in advance,
smrimell

.



Relevant Pages

  • Re: Struts validator question
    ... > I wanted to use the validwhen validator but I have not found a way to ... > validation code and tested it in the action class. ... > validator configuration or in the form/field configuration. ...
    (comp.lang.java.programmer)
  • Re: Validate phone number struts
    ... Struts Validator can do what you are looking for. ... use the mask validator. ... The regular expression might be something like: ...
    (comp.lang.java.help)
  • Re: Validate phone number struts
    ... > Struts Validator can do what you are looking for. ... > use the mask validator. ... The regular expression might be something like: ...
    (comp.lang.java.help)