You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Stanley, Eric" <Er...@qwest.com> on 2009/03/17 18:32:17 UTC

Multiple select

All,
    I cannot get my select to preselect items from groupList using
user.groups. This is my select: 

<s:select label="group" multiple="true" size="4" name="user.groups"
list='groupList' listKey="id" listValue="name" />

This is the actual contents of groupList, and user.groups. Both
collections are List<Group>.

groupList: bmg 1

groupList: wholesale 2

groupList: repair 3

groupList: ebiz 4

groupList: actuate 5

 

user.getGroups(): bmg 1

user.getGroups(): wholesale 2

I am using struts 2 version 2.0.14. Any help would be appreciated.
Please let me know if I can provide more info. Thanks.

E. Ryan Stanley
Phone: 720.578.3703
Pager: 801.482.0172
<ma...@qwest.com>  
 


This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly 
prohibited and may be unlawful.  If you have received this communication 
in error, please immediately notify the sender by reply e-mail and destroy 
all copies of the communication and any attachments.

RE: Multiple select

Posted by Martin Gainty <mg...@hotmail.com>.
interested to know how groupList was populated
?
Martin 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung / Disclaimer and confidentiality note 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
This message is confidential and may be privileged. If you are not the intended recipient, we kindly ask you to  please inform the sender. Any unauthorised dissemination or copying hereof is prohibited. This message serves for information purposes only and shall not have any legally binding effect. Given that e-mails can easily be subject to manipulation, we can not accept any liability for the content provided.






> Subject: RE: Multiple select
> Date: Tue, 17 Mar 2009 14:38:57 -0600
> From: Eric.R.Stanley@qwest.com
> To: user@struts.apache.org
> 
> Figured it out in case anyone has this same issue. Added a value
> attribute, and used OGNL to grab a list of id's from List<Group> instead
> of just the List<Group> which works just fine in a select where
> multiple="true".
> 
> <s:select label="group" multiple="true" size="4" name="user.groups"
> 		value="user.groups.{id}" list='groupList' listKey="id"
> 		listValue="name" />
> 
> -Good luck 
> 
> -----Original Message-----
> From: Stanley, Eric [mailto:Eric.R.Stanley@qwest.com] 
> Sent: Tuesday, March 17, 2009 11:32 AM
> To: Struts Users Mailing List
> Subject: Multiple select
> 
> All,
>     I cannot get my select to preselect items from groupList using
> user.groups. This is my select: 
> 
> <s:select label="group" multiple="true" size="4" name="user.groups"
> list='groupList' listKey="id" listValue="name" />
> 
> This is the actual contents of groupList, and user.groups. Both
> collections are List<Group>.
> 
> groupList: bmg 1
> 
> groupList: wholesale 2
> 
> groupList: repair 3
> 
> groupList: ebiz 4
> 
> groupList: actuate 5
> 
>  
> 
> user.getGroups(): bmg 1
> 
> user.getGroups(): wholesale 2
> 
> I am using struts 2 version 2.0.14. Any help would be appreciated.
> Please let me know if I can provide more info. Thanks.
> 
> E. Ryan Stanley
> Phone: 720.578.3703
> Pager: 801.482.0172
> <ma...@qwest.com>  
>  
> 
> 
> This communication is the property of Qwest and may contain confidential
> or privileged information. Unauthorized use of this communication is
> strictly prohibited and may be unlawful.  If you have received this
> communication in error, please immediately notify the sender by reply
> e-mail and destroy all copies of the communication and any attachments.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Windows Liveā„¢: Life without walls.
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_032009

Re: Multiple select

Posted by Dale Newfield <da...@newfield.org>.
wkbutler wrote:
> Thanks Eric for posting your solution, this helped me remember that unusual
> OGNL syntax on the value attribute.

Once again I'll post my suggestion that the %{} notation be used 
EVERYWHERE you expect the framework to evaluate your expression with 
OGNL so that these are less confusing during subsequent development or 
maintenance.

The "unusual" syntax you describe is an example of the power of OGNL. 
caseFile.sentences is a collection of objects, but what you want is a 
collection of just one field from each of those objects.  The OGNL 
documentation calls this "projection": 
http://www.opensymphony.com/ognl/html/LanguageGuide/projection.html .

I don't have much experience with other EL's...is this type of construct 
possible with the others that people have been suggesting (JUEL, MVEL, 
etc.)?

-Dale

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


RE: Multiple select

Posted by wkbutler <ke...@gmail.com>.
Thanks Eric for posting your solution, this helped me remember that unusual
OGNL syntax on the value attribute.

Because I have not found so many working examples out there, I'll post mine
too:

    <s:select
       label="%{getText('caseFile.sentence')}" 
       name="caseFile.sentences.qualifierId"
       value="caseFile.sentences.{qualifierId}"
       list="availableQualifiers" 
       listKey="qualifierId" 
       listValue="display" 
       emptyOption="false"
       multiple="true"
       theme="css_xhtml" 
       required="false" 
       cssClass="text medium" 
       cssStyle="width:300px" />

CaseFile contains List<Qualifier> called 'sentences'.  
Qualifier looks like
    private Long qualifierId;
    private String code;
    private String description;
    // Transients
    private String display;  // Just transiently defined as code + " - " +
description


Thanks -


Stanley, Eric wrote:
> 
> Figured it out in case anyone has this same issue. Added a value
> attribute, and used OGNL to grab a list of id's from List<Group> instead
> of just the List<Group> which works just fine in a select where
> multiple="true".
> 
> <s:select label="group" multiple="true" size="4" name="user.groups"
> 		value="user.groups.{id}" list='groupList' listKey="id"
> 		listValue="name" />
> 
> -Good luck 
> 
> 

-- 
View this message in context: http://www.nabble.com/Multiple-select-tp22564208p25803112.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


RE: Multiple select

Posted by "Stanley, Eric" <Er...@qwest.com>.
Figured it out in case anyone has this same issue. Added a value
attribute, and used OGNL to grab a list of id's from List<Group> instead
of just the List<Group> which works just fine in a select where
multiple="true".

<s:select label="group" multiple="true" size="4" name="user.groups"
		value="user.groups.{id}" list='groupList' listKey="id"
		listValue="name" />

-Good luck 

-----Original Message-----
From: Stanley, Eric [mailto:Eric.R.Stanley@qwest.com] 
Sent: Tuesday, March 17, 2009 11:32 AM
To: Struts Users Mailing List
Subject: Multiple select

All,
    I cannot get my select to preselect items from groupList using
user.groups. This is my select: 

<s:select label="group" multiple="true" size="4" name="user.groups"
list='groupList' listKey="id" listValue="name" />

This is the actual contents of groupList, and user.groups. Both
collections are List<Group>.

groupList: bmg 1

groupList: wholesale 2

groupList: repair 3

groupList: ebiz 4

groupList: actuate 5

 

user.getGroups(): bmg 1

user.getGroups(): wholesale 2

I am using struts 2 version 2.0.14. Any help would be appreciated.
Please let me know if I can provide more info. Thanks.

E. Ryan Stanley
Phone: 720.578.3703
Pager: 801.482.0172
<ma...@qwest.com>  
 


This communication is the property of Qwest and may contain confidential
or privileged information. Unauthorized use of this communication is
strictly prohibited and may be unlawful.  If you have received this
communication in error, please immediately notify the sender by reply
e-mail and destroy all copies of the communication and any attachments.

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