You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Zoran Avtarovski <zo...@sparecreative.com> on 2007/04/19 18:04:26 UTC

[s2] checkboxlist tag problem

I'm having trouble getting my checkbox list to populate correctly.

I have a User object which has a List of Role objects (roleId-Integer,
roleName-String) with setter/getter as follows:

    private List<Role> roles;

    /**
     * Returns the roles
     *
     * @return the roles
     */
    public List<Role> getRoles() {
        return roles;
    }

    /**
     * Sets the roles
     *
     * @param roles
     *            the new user roles
     */
    public void setRoles(List<Role> roles) {
        this.roles = roles;
    }


My form has the tag configured as below:

<s:checkboxlist list="%{roles}" listKey="roleId" listValue="roleName"
label="Roles" name="user.roles.roleId" id="roles" />

When I submit the form everything works as expected, but when I edit the
User object the roles are populated in the User object but the checkboxes
aren't checked as required.

If somebody could point out my error to me, I'd appreciate it.

Zoran



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


Re: [s2] checkboxlist tag problem

Posted by Zoran Avtarovski <zo...@sparecreative.com>.
The id attribute is for some JavaScript that will run once I get over this
little hurdle.

Do you mind sending me a copy of your domain object, action code and jsp
file. I'm getting nowhere here and it's becoming quite frustrating.

The issue I'm having now is that if I have no checkboxes selected the setter
method isn't being called a and roles don't change.

Z.



> Looks like you need <s:checkboxlist name="user.roles" instead of
> name="user.roles.roleId". Be sure roles is set on the user object from
> the action. 
> I'm doing two collections. #1 for the full list of checkboxes and #2 for
> the boxes I want pre-checked.
> What are you doing with the attribute id="roles"?
> -------
> 
> I'm having trouble getting my checkbox list to populate correctly.
> 
> I have a User object which has a List of Role objects (roleId-Integer,
> roleName-String) with setter/getter as follows:
> 
>     private List<Role> roles;
> 
>     /**
>      * Returns the roles
>      *
>      * @return the roles
>      */
>     public List<Role> getRoles() {
>         return roles;
>     }
> 
>     /**
>      * Sets the roles
>      *
>      * @param roles
>      *            the new user roles
>      */
>     public void setRoles(List<Role> roles) {
>         this.roles = roles;
>     }
> 
> 
> My form has the tag configured as below:
> 
> <s:checkboxlist list="%{roles}" listKey="roleId" listValue="roleName"
> label="Roles" name="user.roles.roleId" id="roles" />
> 
> When I submit the form everything works as expected, but when I edit the
> User object the roles are populated in the User object but the
> checkboxes
> aren't checked as required.
> 
> If somebody could point out my error to me, I'd appreciate it.
> 
> Zoran
> 



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


RE: [s2] checkboxlist tag problem

Posted by "Hartrich, James CTR USTRANSCOM J6" <Ja...@ustranscom.mil>.
Looks like you need <s:checkboxlist name="user.roles" instead of
name="user.roles.roleId". Be sure roles is set on the user object from
the action. 
I'm doing two collections. #1 for the full list of checkboxes and #2 for
the boxes I want pre-checked. 
What are you doing with the attribute id="roles"?
-------

I'm having trouble getting my checkbox list to populate correctly.

I have a User object which has a List of Role objects (roleId-Integer,
roleName-String) with setter/getter as follows:

    private List<Role> roles;

    /**
     * Returns the roles
     *
     * @return the roles
     */
    public List<Role> getRoles() {
        return roles;
    }

    /**
     * Sets the roles
     *
     * @param roles
     *            the new user roles
     */
    public void setRoles(List<Role> roles) {
        this.roles = roles;
    }


My form has the tag configured as below:

<s:checkboxlist list="%{roles}" listKey="roleId" listValue="roleName"
label="Roles" name="user.roles.roleId" id="roles" />

When I submit the form everything works as expected, but when I edit the
User object the roles are populated in the User object but the
checkboxes
aren't checked as required.

If somebody could point out my error to me, I'd appreciate it.

Zoran



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


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