This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes how to get label property from html:OptionsCollection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to get label property from html:OptionsCollection" Watch "how to get label property from html:OptionsCollection" New topic
Author

how to get label property from html:OptionsCollection

Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Hi All,
I have a <html:select > which is populated with a <html ptionsCollection>. The collection "groups" from the code snippet below is a list of LabelValue beans. I can get at the selected value in my struts action by using the the getGroupId method I put in my struts form. My question is , how do I get at the label ? For example, if the user selects the item of my collection ["groupxyz", 5], a call to getGroupID will return 5. I want to know how to get the "groupxyz" string from my struts action. I tried to add a member to the struts form called "groupName" thinking that struts would put the label value there, but got an error.

Here is the jsp code :



[ November 30, 2005: Message edited by: Kim Kantola ]

[ November 30, 2005: Message edited by: Kim Kantola ]
[ November 30, 2005: Message edited by: Kim Kantola ]
pankajjj jain
Greenhorn

Joined: Oct 12, 2005
Posts: 14
I am getting the same type of problem that when I use opencollections then the label and value of the options are same.


I think I am doing something wrong in the java files can you please send me the sample java code for putting value in the collection so that label and value of options in the select are different
 
Consider Paul's rocket mass heater.
 
subject: how to get label property from html:OptionsCollection