Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Values of multiple <select> tag are not being selected

Célio Cidral Junior

2006-12-20

Replies:

Given the following code:

myPage.jsp:

<s:select name="selectedRoles" list="allRoles" listKey="id"
listValue="name" multiple="true"
label="%{getText('roles')}"></s:select>

MyAction.java:

public Set<String> getSelectedRoles() {
 Set<String> ids = new HashSet<String>();
 
 for (Role role : selectedRoles)
   ids.add(Integer.toString(role.getId()));
 
 return ids;
}

public List<Role> getAllRoles() {
 return roleDao.list();
}

All the available roles are properly loaded to the list but the ones
returned by getSelectedRoles() are not appearing selected in the list.
I have compared my code against the Employees Manager's (from
struts2-showcase-2.0.1) and my code seems to be correct. In addition,
I debugged getSelectedRoles() to check if the selected role ids are
being correctly returned, and they actually are.

I can't catch anything wrong in my code. Could anybody help me on this?

Regards,

Célio.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.