You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Caroline Jen <ji...@yahoo.com> on 2004/09/29 15:26:40 UTC
The Value of a Property in a Drop-Down Menu
My Collection, PageBeans (plural), generates a
drop-down list like this:
<html-el:select property="document">
<html-el:option value="">-Select-</html-el:option>
<html-el:options collection="PageBeans"
property="name" labelProperty="name"/>
</html-el:select>
Each individual bean, PageBean (singular), in the
Collection has two properties; name and groupID. I
want to display 'name' in the drop down list.
However, I want the 'value' of 'groupID' to be
submitted when users click on the Submit button.
Therefore, the statement in the servlet:
String selected = request.getParameter( "document" );
picks up the value of the 'groupID' instead. Do I
change the generation of the drop-down menu:
<html-el:select property="document">
<html-el:option value="">-Select-</html-el:option>
<html-el:options collection="PageBeans"
property="groupID" labelProperty="name"/>
</html-el:select>
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: The Value of a Property in a Drop-Down Menu
Posted by Matt Bathje <mp...@ntsource.com>.
Caroline Jen wrote:
> My Collection, PageBeans (plural), generates a
> drop-down list like this:
>
> <html-el:select property="document">
> <html-el:option value="">-Select-</html-el:option>
> <html-el:options collection="PageBeans"
> property="name" labelProperty="name"/>
> </html-el:select>
>
> Each individual bean, PageBean (singular), in the
> Collection has two properties; name and groupID. I
> want to display 'name' in the drop down list.
> However, I want the 'value' of 'groupID' to be
> submitted when users click on the Submit button.
>
> Therefore, the statement in the servlet:
>
> String selected = request.getParameter( "document" );
>
> picks up the value of the 'groupID' instead. Do I
> change the generation of the drop-down menu:
>
> <html-el:select property="document">
> <html-el:option value="">-Select-</html-el:option>
> <html-el:options collection="PageBeans"
> property="groupID" labelProperty="name"/>
> </html-el:select>
>
Yes, that should work - "property" holds the values that will be passed
with the form, and "labelProperty" holds the labels that will be seen by
the user.
Matt
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org