• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Struts Html select tag

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
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

thanks

suchendra
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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"/>
</html:select>

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.
raminder.s
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic