You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by st...@trexart.com.au on 2007/04/17 05:20:58 UTC

Struts2 select tag multiple select

I have a form where I populate a select tag with a list of possible roles. What I now want to do is pre-select all of the roles that the user I am editing already belongs to. I have searched every possible place I can and have tried all possible ways people have suggested but I just can't get it to work. 

Here is how I currently have the tag:

<s:select list="roles" listKey="id" listValue="name" name="selectedRoles" multiple="true" size="5"/>

Where 'roles' is a list of Role objects that I populate in the Action, id is a Long field and name is a String field in the Role object. The object 'selectedRoles' is a List of Longs that represent the roles that the user currently belongs to.

I had originially tried using the list of roles in my user object to select which roles the user belongs to, but I couldn't get that to work, so I switched to just having a seperate List. I think at one point I had something similar to the following:

<s:select list="roles" listKey="id" listValue="name" name="user.roles" value="%{user.roles.{id}}" multiple="true" size="5"/>

or something similar to that.

If anyone could give me a hand I would be so happy. I have been stuck on this one thing for a stupidly large amount of time.

Cheers,
Steph


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


Re: Struts2 select tag multiple select

Posted by Stephanie <st...@trexart.com.au>.
Thank you, that was it. I updated to 2.0.7 and it works now. I can't believe I didn't think to look through the Jira issues.

Thanks a bunch.

On Tue, 17 Apr 2007 14:41:11 +0000 (UTC), Nate Drake <nd...@gmail.com> wrote:
> What version of Struts2 are you using?  There is a bug in versions before
> 2.0.7,
> where the select tag won't pre-select your values unless it is comparing
> Strings.
> 
> See this Jira issue for details:
> 
> https://issues.apache.org/struts/browse/WW-1711
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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


Re: Struts2 select tag multiple select

Posted by Nate Drake <nd...@gmail.com>.
What version of Struts2 are you using?  There is a bug in versions before 2.0.7,
where the select tag won't pre-select your values unless it is comparing 
Strings.  

See this Jira issue for details:

https://issues.apache.org/struts/browse/WW-1711






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