File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

selecting a value in dropdown

 
Ar Reddy
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is your list values getting displayed on the page ? If yes you can just use this attribute listKey="id" .
 
Ar Reddy
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah with %{calculationName} it's getting dispalyed. My question is how will I get ID?
 
Ar Reddy
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<s:select id="calculationID" list="%{calculationName}" listKey="calculationID" listValue="calculationName" />
I guess this should help .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic