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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Retain a selected value in a drop down." Watch "Retain a selected value in a drop down." New topic
Author

Retain a selected value in a drop down.

Ash Acharya
Greenhorn

Joined: Jan 09, 2009
Posts: 11
Hi,
I have a jsp wherein I have a select box, which gets populated from the database on form load. How do I get the selected value in the drop down when i visit the same page again?what I exactly mean is that i want to retain the previously selected value in the select box the next time i revisit the same page. I'm able to populate the other text fields on the form with the values they originally had, when i revisit the page. How can I achieve this?


regards,
Ash.
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

You need to make sure that the name attribute in select tag matches the getter for the selected value.
If that is not possible for some reason, you should be able to set the selected option by setting it explicitly in the value attribute.


The future is here. It's just not evenly distributed yet. - William Gibson
Consultant @ Xebia. Sonny Gill Tweets
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retain a selected value in a drop down.