我想創建一個帶自動完成功能的下拉菜單。我有一個角色對象,具有屬性roleId,roleDescription。我的搜索框只能在roleDescription上自動完成。我跟着這個例子:
http://code.google.com/p/struts2-jquery/wiki/AutocompleterTagstruts2自動完成功能
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();
}
}
我改變ParentPackage到struts-默認情況下,它仍然無法正常工作。 :( – Nish 2010-07-23 20:39:34
我不認爲jquery觸發autocompleter行動。 – Nish 2010-07-24 00:05:01