Win a copy of Spring Boot in Practice this week in the Spring 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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 .
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic