Reputation: 4000
The following TreeMap
is having all the values from the database which I am passing with
Map<String, String> treeMap = new TreeMap<String, String>(map);
Iterator mapIterator = mapSet.iterator();
while (mapIterator.hasNext()) {
Map.Entry mapEntry = (Map.Entry) mapIterator.next();
String keyValue = (String) mapEntry.getKey();
String value = (String) mapEntry.getValue();
System.out.println("Key : " + keyValue + "= Value : " + value);
}
request.setAttribute("airline_name", treeMap);
In JSP page:
<html:select property="airline_name_value" styleId = "tempId" >
<html:options collection="airline_name" property="key" labelProperty="key" />
</html:select>
In ActionForm
:
private String airline_name;
public String getAirline_name() {
return airline_name;
}
public void setAirline_name(String airline_name) {
this.airline_name = airline_name;
}
Error:
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find bean under name airline_name
Is there any other way to use <html:options>
collection tag?
Upvotes: 1
Views: 7773
Reputation: 1
There's another way to not use html:options
but use html:optionsCollection
instead.
<html:optionsCollection property="airlines" label="value" value="key" />
To make this working you should map the property in the form
private Map<String, String> airlines;
public Map<String, String> getAirlines() {
return airlines;
}
public void setAirlines(Map<String, String> airlines) {
this.airlines = airlines;
}
in the action
form.setAirlines(treeMap);
Upvotes: 3