I have a variable:
private ArrayList<LabelValueBean> circleNameIdList;
inside my Action
class where it's value get populated.
I want to display the label in my drop-down in JSP and when one label is selected, the corresponding value to that particular label in circleNameIdList
to be passed to the server.
Eg.: If label: NewYork
is selected then it's corresponding id = 5
, is sent to the server.
How can I achieve this?
Up till now I was doing like this in JSP:
<s:select list="#session.circleNameIdList" label="Select Circle:" name="circleNameIdList" id="circleNameIdList"></s:select>
However, it display is not correct.
I see you are using a
LableValueBean
to populate and show a dropdown. It's a former bean used at last to display a list of objects. In Struts2 you're no longer required such a helper bean. You can display a list of objects by specifying a key field that would hold a unique value of the selected option and a value to be shown as the option text. For example if your objectand you have in the action class
then
could be used to show the dropdown.