This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes html:select - maintain incoming value in drop down box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:select - maintain incoming value in drop down box" Watch "html:select - maintain incoming value in drop down box" New topic
Author

html:select - maintain incoming value in drop down box

M Mills
Greenhorn

Joined: Sep 16, 2005
Posts: 2
Hi,
I am having trouble deciding how to display a property populated from Hibernate (via setAttribute()) on the jsp. On the jsp, I have a Struts <html:select> tag. If a value is retrieved from the (DB2) database and sent to the jsp's select which does not match any of the <html ption> elements (drop down box), the first option's value is always displayed. What I need is to display, in this case, the unmatched value coming from the database and highlight the background to indicate a data error. Here is an excerpt of my code:



I am new to Struts tags and saw some <logic:> tags on the Apache Jakarta website. Perhaps I should use <logic:iterate> and/or <logic:nonMatch> ? But I never was able to find exactly what I needed.

Any advice is greatly appreciated. Thanks.
Srilakshmi Vara
Ranch Hand

Joined: Jul 21, 2004
Posts: 169
Instead of using html ption, can use html ptions which takes any java.util structure(List, ArrayList, Map, HashMap)

Make sure to populate the list before displaying the jsp using action class.


Srilakshmi
M Mills
Greenhorn

Joined: Sep 16, 2005
Posts: 2
That sounds simple enough and a good idea. I'll give it a try. Thank you very much for your response!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: html:select - maintain incoming value in drop down box
 
Similar Threads
javascript issue in struts for onchange event
Setting a preselected value in a combo
Update user profile
whats problem with following code ** urgent
validation.xml - how to ignore the required fields if a checkBox was clicked?