This week's book giveaway is in the Java in General forum.
We're giving away four copies of Helidon Revealed: A Practical Guide to Oracle’s Microservices Framework and have Michael Redlich on-line!
See this thread for details.
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

selecting a value in dropdown

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<s:select id="calculationID" list="%{calculationName}" listKey="calculationID" listValue="calculationName" />
I guess this should help .
 
Never trust an airline that limits their passengers to one carry on iguana. Put this tiny ad in your shoe:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic