aspose file tools*
The moose likes Struts and the fly likes selecting a value in dropdown Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "selecting a value in dropdown" Watch "selecting a value in dropdown" New topic
Author

selecting a value in dropdown

Ar Reddy
Greenhorn

Joined: Nov 03, 2008
Posts: 20
I am trying to select a name from drop down list. When the user selects a name from the dropdown I need to get that ID from that list.
How can I do that. In my action calss have list with name and id values. I seperated names and ids and stored in different lists and used name list while showing it on jsp page.
please help me how can i get the id value from the drop down list.
this is the code from jsp page.

<s:select list="%{calculationName}" key="label.calculationName"></s:select>



Thanks,
Arpitha
Sanal Samuel
Greenhorn

Joined: Jul 23, 2010
Posts: 8
You Do Not need to create 2 objects.You can use your list object to display some data and pass some id.
For e.g
<s:select label="Pets"
name="petIds"
list="petDao.pets"
listKey="id"
listValue="name"
multiple="true"
size="3"
required="true"
value="%{petDao.pets.{id}}"
/>

Ar Reddy
Greenhorn

Joined: Nov 03, 2008
Posts: 20
Thanks for your reply.
i am trying to display all list values with struts tag and need to get an ID for selected value. Please explain me in detail.
this is my code.
<s:select name="calculationID" list="%{calculationName}" key="label.calculation" ></s:select>
thanks,
Arpitha
Sanal Samuel
Greenhorn

Joined: Jul 23, 2010
Posts: 8
is your list values getting displayed on the page ? If yes you can just use this attribute listKey="id" .
Ar Reddy
Greenhorn

Joined: Nov 03, 2008
Posts: 20
Yeah with %{calculationName} it's getting dispalyed. My question is how will I get ID?
Ar Reddy
Greenhorn

Joined: Nov 03, 2008
Posts: 20
Thanks for your reply,
<s:select name="calculationID" list="%{calculationName}" key="label.calculation" ></s:select>
witht his stmt I am getting all my calculation names are coming. in my bean I have list for ids "calculationID" do I need to use this for listkey="calculationID"?
please let me know.
Thanks
Sanal Samuel
Greenhorn

Joined: Jul 23, 2010
Posts: 8
<s:select id="calculationID" list="%{calculationName}" listKey="calculationID" listValue="calculationName" />
I guess this should help .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: selecting a value in dropdown