I am new to Struts and am having problems populating drop-downs from the
database. I am actually getting a little frustrated with these tags,
seems like not coding in java anymore.
1. ActionClass code excerpt:
mBean.makeConnection(); //db connection made thru helper class
//get country list vector
Vector v = (Vector)mBean.getCountryList();
request.setAttribute("lstCountry", v)
2. The vector contains a list of CountryObjects, here's an excerpt
from the CountryObject class:
/* Country ID */
private String country_id;
public String getCountryId() {
return (this.country_id);
}
public void setCountryId(String id) {
this.country_id = id;
}
/* Country Code*/
private String code = null;
public String getCountryCode() {
return (this.code);
}
public void setCountryCode(String code) {
this.code = code ;
}
3. JSP code excerpt:
The vector lstCountry contains CountryObject beans that have getters and setters
for country_id and name.
<html:select property="countryId">
<html
ptions collection="lstCountry" property="country_id" labelProperty="name"/>
</html:select>
Any help is greatly appreciated!
Thanks,
Abhi