Hello all,

I'm trying to get my code to work with indexed properties. Thanks to Dave Hay and his 
Struts tweak, I was able to generate input types like this:
<input type="text" name="users[0].username" size="12" value="">
<input type="text" name="users[0].role" size="12" value="">

using the following Struts tags:
<html:text name="users" property="username" size="12" indexed="true"/>
<html:text name="users" property="role" size="12" indexed="true"/>

The problem is that I cannot get my ActionForm to pick up these input fields. I wrote 
several setters and getters in my ActionForm:
   /**
     * Return the users.
     */
    public String getUsers(int i) {

        return (users[i].getUsername());

    }


    /**
     * Set a user.
     *
     * @param user
     * @param index
     */
    public void setUsers(int i, String user) {
            this.users[i].setUsername(user);

    }
 
 
    /**
     * Return the users.
     */
    public User[] getUsers() {

        return (this.users);

    }


    /**
     * Set a user.
     *
     * @param user list
     */
    public void setUsers(User[] users) {
        this.users = users;

    }
 
    /**
     * Return the roles.
     */
    public String getRoles(int i) {

        return (users[i].getRole());

    }


    /**
     * Set a role.
     *
     * @param role
     * @param index
     */
    public void setRoles(int i, String role) {

        this.users[i].setRole(role);

    }
 
 
    /**
     * Return the roles.
     */
    public User[] getRoles() {

        return (this.users);

    }


    /**
     * Set a role.
     *
     * @param role list
     */
    public void setRoles(User[] roles) {

        this.users = users;

    }             


Do you see anything wrong with this scheme? Currently, the ActionForm returns null for 
all items in the User[] when I call any of the get methods. Please help.

~Jason

Reply via email to