You can put the validation on Person's firstName() method. On Tue, Jul 1, 2008 at 12:39 PM, Asleson, Ryan <[EMAIL PROTECTED]> wrote:
> > Hello, > > I'm using Struts 2.0.11. > > I have an HTML table. Each row in the table represents a Person object. > Each column in the table has an input box for properties about the > person, such as firstName, lastName, etc. > > My Action has a Persons property that is a List<Person>. Each input box > in the HTML table is indexed so as to populate the correct Person, for > example: > > <input type="text" name="persons[0].firstName" value="Fred" /> > > When the user posts the form, Struts 2 will populate the Person objects > appropriately. So far so good. However, I want to apply validations to > the input. For example, firstName is required. I want to use > annotations for these validations as that is how I've done it elsewhere. > > I added this annotation to the method in the Action: > > @Validations( > requiredStrings={ > @RequiredStringValidator( type=ValidatorType.SIMPLE, fieldName = > "persons.firstName", message = "person.firstname.required" ) > } > ) > > Hoping that the firstName property of each Person within List<Person> > would be checked to see if a value is provided. However, it doesn't > seem to work; it always reports an error, even if all of the firstName > input boxes are filled in. > > How can I validate the contents of objects within collections using > annotations? > > Thank you!!! > > -Ryan > > > > > > This e-mail message is being sent solely for use by the intended > recipient(s) and may contain confidential information. Any unauthorized > review, use, disclosure or distribution is prohibited. If you are not the > intended recipient, please contact the sender by phone or reply by e-mail, > delete the original message and destroy all copies. Thank you. -- Jim Kiley Technical Consultant | Summa [p] 412.258.3346 [m] 412.445.1729 http://www.summa-tech.com