Sun Jie
Fri, 20 Nov 2009 04:51:58 -0800
Hi all,I am trying to validate a select box using Struts 2.1.8. The select box is a required form element, and by default it is empty. I need to validate that values have been put into it before it is submitted.
_Struts select box:_<s:select name="myIds" list="myList" listKey="id" listValue="name" size="8" multiple="true" required="true" theme="simple" />
_Struts XML Validator:_
<field name="myIds">
<field-validator type="required" >
<message key="this.is.required"/>
</field-validator>
</field>
When I use the above snips, the XML validator does not catch that the
select box is empty.
I have tried using validate() to make sure that an empty select box cannot be submitted. I could not get this to work. The array I get is of size 0 and setting the array to null doesn't help me either.
Does anyone know how to do this? --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org