Few days back i also posted the query much similar to yrs, i am attaching the reply i got from Matt below for yr reference. Hope this helps u regards Manisha Manisha Sathe wrote: > I have a form whose fields are from an dynamic customer array. I display Customer name and giving i/p field for Amount to enter. > > The JSP might contain 2-3 text fields called amt against different customers (I am identifying it with IDs) > > My form bean is something like this, > > public class AddressForm extends ValidatorForm > //ActionForm > { > ... > private String[] amt; > ... > public String[] getAmt() > { > return this.amt; > } > public void setAmt(String[] amt) > { > this.amt = amt; > } > > ... > } > > I am using Validator, > > validation.xml is something like this > > <field property="amt" > depends="required"> > <arg0 key="amt.displayname"/> > </field> > > -------------------------------------------------------------------------------- > > 1) When validation fails and it comes back to jsp form -BUT the bydefault values of Amount is something like : [Ljava.lang.String;@f2da21 > > I understand this is because i have declared it as an array. But how to get rid of this. > > 2)I face a problem when i also want to validate as float. As i/p taken is amt[1], amt[2] ... it never gets validated as float where as i want to validate individual i/p text field as float. > > How can i achieve it ? >
Manisha - I think these messages in the archives are very similar to your problem. http://www.mail-archive.com/user@struts.apache.org/msg18871.html http://www.mail-archive.com/user@struts.apache.org/msg18895.html http://www.mail-archive.com/user@struts.apache.org/msg18925.html As well as this bug report: http://issues.apache.org/bugzilla/show_bug.cgi?id=32978 Basically you can't validate each element of an array of String[] with the validator, because it does not have getters/setters for its value. Your choices are to use the validate method in the action form to do the validation, or to setup a new class with an amount property and getters/setters for the amounts, then use an array of that instead of String[] Matt Paulo César M. Jeveaux <[EMAIL PROTECTED]> wrote: Hi I have html form which containes product name and product no. these product name and product number can be in 'N' Numbers. For this i have taken Array of Product Names and Product Number. But i am unable to validate these arrays . Can You please tell me how we can validate array. T+ -- /** * @author Paulo César M. Jeveaux * Java Consultant * @version 21.0 * http://www.portaljava.com * @deprecated */ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------- Do you Yahoo!? Yahoo! Search presents - Jib Jab's 'Second Term'