You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Narayana S <na...@gmail.com> on 2008/07/17 12:33:42 UTC

Checkbox List Problem...

Hi,

    In my form I have employee number, name, and roles, here employee number
and name are text fields and roles is a checkboxlist, to generate the list
boxes i had a map called rolesMap in my action class, as well i have a set
called userRoles that specifies the items to be selected.
*jsp*

<s:checkboxlist key="roles" list="rolesMap" value="userRoles"
name="userRoles" />

*action class*

    public Set<Long> getUserRoles() {
        return userRoles;
    }

@RequiredFieldValidator(type=ValidatorType.SIMPLE,fieldName="userRoles",message="",key="requiredstring")
    public void setUserRoles(Set<Long> userRoles) {
        this.userRoles = userRoles;
    }
    public Map<Long, String> getRolesMap() {
        generateRoles();
        return rolesMap;
    }
    public void setRolesMap(Map<Long, String> rolesMap) {
        this.rolesMap = rolesMap;
    }
    private generateRoles(){
     ----
     ----
    }

it is coming fine when i generate the form, but when i submit the form it is
throwing exception....
*stack trace ...*

Jul 17, 2008 2:25:33 PM org.apache.catalina.core.ApplicationDispatcher
invoke
SEVERE: Servlet.service() for servlet jsp threw exception
tag 'checkboxlist', field 'list', name 'userRoles': The requested list key
'rolesMap' could not be resolved as a
collection/array/map/enumeration/iterator type. Example: people or
people.{name} - [unknown location]
    at
org.apache.struts2.components.Component.fieldError(Component.java:231)
    at org.apache.struts2.components.Component.findValue(Component.java:293)
    at
org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:79)

i couldnt find the fix for this... can any one please guide me to solve this
problem.

Re: Checkbox List Problem...

Posted by Narayana S <na...@gmail.com>.
Hi,

 Please discard this email. as my action mapping is wrong it is behaving
like this, now i could fix the issue.

Sorry.

On Thu, Jul 17, 2008 at 4:03 PM, Narayana S <na...@gmail.com> wrote:

> Hi,
>
>     In my form I have employee number, name, and roles, here employee
> number and name are text fields and roles is a checkboxlist, to generate the
> list boxes i had a map called rolesMap in my action class, as well i have a
> set called userRoles that specifies the items to be selected.
> *jsp*
>
> <s:checkboxlist key="roles" list="rolesMap" value="userRoles"
> name="userRoles" />
>
> *action class*
>
>     public Set<Long> getUserRoles() {
>         return userRoles;
>     }
>
> @RequiredFieldValidator(type=ValidatorType.SIMPLE,fieldName="userRoles",message="",key="requiredstring")
>     public void setUserRoles(Set<Long> userRoles) {
>         this.userRoles = userRoles;
>     }
>     public Map<Long, String> getRolesMap() {
>         generateRoles();
>         return rolesMap;
>     }
>     public void setRolesMap(Map<Long, String> rolesMap) {
>         this.rolesMap = rolesMap;
>     }
>     private generateRoles(){
>      ----
>      ----
>     }
>
> it is coming fine when i generate the form, but when i submit the form it
> is throwing exception....
> *stack trace ...*
>
> Jul 17, 2008 2:25:33 PM org.apache.catalina.core.ApplicationDispatcher
> invoke
> SEVERE: Servlet.service() for servlet jsp threw exception
> tag 'checkboxlist', field 'list', name 'userRoles': The requested list key
> 'rolesMap' could not be resolved as a
> collection/array/map/enumeration/iterator type. Example: people or
> people.{name} - [unknown location]
>     at
> org.apache.struts2.components.Component.fieldError(Component.java:231)
>     at
> org.apache.struts2.components.Component.findValue(Component.java:293)
>     at
> org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:79)
>
> i couldnt find the fix for this... can any one please guide me to solve
> this problem.
>