aspose file tools*
The moose likes Struts and the fly likes In List Highlighting previous selected values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "In List Highlighting previous selected values" Watch "In List Highlighting previous selected values" New topic
Author

In List Highlighting previous selected values

Gajen Pingalkar
Ranch Hand

Joined: Aug 29, 2006
Posts: 37
hi,
In my application, I have one list box, as per the code.

<select Name="Entity" multiple="true" size="">
<logic:iterate id="Price" name="Price" property="basePriceTypePresList">
<logic:iterate id="ent" name="Price" property="ent">
<option value="<bean:write name="ent" property="key"/>">
<bean:write name="ent" property="value"/>
</logic:iterate>
</logic:iterate>
</select>

If i select one option from list box , for time being it display as selected and when i submit this page and again come to this page. That time, i want to show selected item of list how to do this(i.e. highlighting previously selected values), pls suggest

-Gajendra
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5

I am not sure we understand your requirement. You want to submit this page and then reload the same page with the selected values ?


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

First, "pls" is not a word in the English language.
See:
http://faq.javaranch.com/view?UseRealWords
to find out why using real words is important to us.

Adding the "selected" attribute to your option tag will cause it to be drawn on the page as selected.

The logic:iterate tag is a Struts tag isn't it?
If so, I believe there is a Struts specific way to build select lists.
Moving to our Struts forum where someone will be able to explain how to use those tags better than we could.
[ April 24, 2007: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you use either <htmlptions> or <htmlptionsCollection> along with <html:select>, Struts will automatically show the correct item as selected when the page is redisplayed.
[ April 24, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
 
wood burning stoves
 
subject: In List Highlighting previous selected values