Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

selecting a value in dropdown

 
Greenhorn
Posts: 20
  • 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
 
Greenhorn
Posts: 8
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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 .
 
brevity is the soul of wit - shakepeare. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic