Reputation: 2873
I'm having problems pre-selecting a value on a with struts 2.
I'm using the tag value="country" to target to a String country="Japan" , and the select loads the elements from a list (string list).
But, on load the select just target the first item on the list.
look:
<s:select list="countries" value="country" label="Conutry"
headerKey="null" name="country" id="selectCountry"
/>
public List<String> countries;
public String country;
.....
public Countries(){
countries=dao.list();
}
.........
getter and setter
........
//Action Used to get information
public getInfo(){
country="USA"
}
Upvotes: 0
Views: 2657
Reputation: 10017
try:
<s:select list="countries"
value="country"
label="Conutry"
headerKey="country"
headerValue="contry"
name="countries"
id="selectCountry"/>
headerKey
indicates the value you are posting.
headerValue
will be shown on the list.
Upvotes: 1