struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Raible <m...@raibledesigns.com>
Subject Validator: validating indexed properties
Date Tue, 17 Dec 2002 14:38:38 GMT
I have been given the impression that the Validator can be used to 
validate indexed properties in a form.  I'm trying to figure out the 
validation.xml syntax to perform this validation.

If I have a GroupForm that contains an ArrayList of UserForms, how do I 
configure validation.xml?

For instance:

public GroupForm extends ValidatorForm {

	private ArrayList users;

	public ArrayList getUsers() {
		return users;
	}

	public void setUsers(ArrayList users) {
		this.users = users;
	}

	public UserForm getUser(int index) {
		return (UserForm) users.get(index);
	}

	public void setUser(int index, UserForm user) {
		this.users.set(index, user);
}

I've seen the indexedPropertyList attribute in the validation.xml's 
DTD, but I'm wondering how to use it.  Will something like this work?

<field property=”groupName”
        depends=”required” indexedListProperty="users">
     <var>
         <var-name>field[0]</var-name>
         <var-value>name</var-value>
       </var>
       <var>
         <var-name>field-indexed[0]</var-name>
         <var-value>true</var-value>
       </var>
       <var>
         <var-name>field-test[0]</var-name>
         <var-value>NOTNULL</var-value>
     </var>
</field>

Thanks for any advice,

Matt
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message