Hi,
I want to create a drop down menu with autocomplete feature. I have a role object with properties roleId, roleDescription. My search box should only autocomplete on roleDescription. I followed this example:
http://code.google.com/p/struts2-jquery/wiki/AutocompleterTag
autocompleter-select.jsp
<sj:autocompleter
id="roles"
name="echo"
list="%{roles}"
listValue="roleDescription"
listKey="roleId"
selectBox="true"
/>
Autocompleter.java
@ParentPackage(value = "com.project.action")
public class Autocompleter extends BaseAction {
private String term;
@Actions( {
@Action(value = "/autocompleter-select", results = { @Result(location = "autocompleter-select.jsp", name = "success") }),
@Action(value = "/autocompleter", results = { @Result(location = "autocompleter.jsp", name = "success") }),
})
public String execute() throws Exception {
return SUCCESS;
}
public void setTerm(String term) {
this.term = term;
}
public List<Role> getRoles() {
System.out.println("getting roles");
return services.getRoles();
}
}