You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by newbee7 <ba...@gmail.com> on 2011/05/01 18:35:49 UTC

Struts2 validation on List of String data

How do i use any validation of struts on List of string inputs(instead of
single String)?

For an instance My action having name field as

MyAction extends ...
{
String[]  names;
// OR

ArrayList names;
}

i want to validate RequiredStringValidator  validator on these names. 
--
View this message in context: http://struts.1045723.n5.nabble.com/Struts2-validation-on-List-of-String-data-tp4363039p4363039.html
Sent from the Struts - User mailing list archive at Nabble.com.

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


Re: Struts2 validation on List of String data

Posted by Eric Lentz <Er...@sherwin.com>.
> String[]  names;
>// OR
>
>ArrayList names;
>}

>i want to validate RequiredStringValidator  validator on these names. 

I don't think the standard validations deal with arrays. Probably your 
best bet is to override validate() and validate on your own. See:

http://struts.apache.org/2.1.6/struts2-core/apidocs/com/opensymphony/xwork2/Validateable.html
http://struts.apache.org/2.1.6/struts2-core/apidocs/com/opensymphony/xwork2/ValidationAware.html
http://struts.apache.org/2.1.6/struts2-core/apidocs/com/opensymphony/xwork2/ActionSupport.html 
(which implements those interfaces)