You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Keld Helbig Hansen <ke...@helbig.dk> on 2003/05/30 13:48:51 UTC

Validation of string array for DynaValidatorForm

I'd like to do this:
Check if a user has selected at least one item in a multi select drop down.
And I'd like to use the Struts Validator for this.
I use  v. 1.1 RC.

If I have an old  standard Struts ActionForm bean where this drop down is implemented as a String array, then validation 'required' works if I specify this validation rule:

<field property="interests" depends="required">
  <arg0 key="validateform.interests"/>
</field>

However, if I replace the bean with a DynaValidatorForm like this:

<form-bean      name="submitDynaValidateForm"
                    type="org.apache.struts.validator.DynaValidatorForm">
  <form-property name="interests" type="java.lang.String[]"/>
</form-bean>

then it doesn't work any more. I don't get an error message telling me to pick an item from the drop down.

In my Action class I get a zero length array, so I could validate at this spot, but of course I'd like to validate using the validation.xml file.

Any ideas why it doesn't work - or how I could implement the validation?

/Keld 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org