File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts Html select tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Html select tag" Watch "Struts Html select tag" New topic

Struts Html select tag

Kumar Suchendra

Joined: Mar 03, 2006
Posts: 1
I am using html:select tag and populating it dynmically with values from the database. As soon as i select second value from the drop down combo box list, the same page will be refreshed with different set of page contents.

The only problem is that the drop down combo box is set to the selected value. But it points to the first value in the list.

Pl. let me know how to retain the selected value


Raminder Singh
Ranch Hand

Joined: Mar 01, 2002
Posts: 72

One example showing how to fill countries in a select box.
countryList = list of all countries from DB
country = form level variable (representing selected country)

Let say you are using this in JSP:
<html:select name="FFAgencyForm" property="country" styleClass="se1">
<html ption value="">Select a Country</html ption>
<html ptionsCollection property="countryList" value="countryCode" label="countryName"/>

now in Action, you do:

ArrayList countryList= ffAgencyBO.getCountryList(); // get list
form.setCountryList(countryList); // set list to select

To show selected value, pass value of that selected Text to set the variable that is represented by this list.
i.e. form.setCountry(request.getParameter("country"));

hope it works.
yamini venkat venkatesan

Joined: May 31, 2006
Posts: 1
hi ,
i am new struts,
i need to populate the combo with selected value (i can get this select value using session from another jsp).
without submitting the page i need to select the next combo.

this is possible ??? or not???

please help me.
I agree. Here's the link:
subject: Struts Html select tag
jQuery in Action, 3rd edition