struts2 jquery plugin
最近工作上的需要一個autocomplate的功能,雖然很多套件都有此功能,總得找個容易上手的套件,第一個找到的套件是:struts2-dojo-pluging,看完文章後想說既然有dojo,那有沒有jquery plugin 呢?谷哥一下後找到:http://code.google.com/p/struts2-jquery/,試用後就決定是他了。
簡單的使用方式:
在Action中
private List queryList; // 需要再加上 set / get 的method
public String edit() {
queryList = new ArrayList();
queryList.add("TW");
queryList.add("US");
queryList.add("JP");
queryList.add("IT");
queryList.add("FR");
return SUCCESS;
}
在jsp中的使用方式:
<sj:autocompleter id="lanauages" name="lanauagesName" list="%{queryList}"/>
另外需要加上:
<sj:head jqueryui="true"/>
這個 head就是載入jquery js的相關作業,若您需要使用新版本的jquery,可以自行在原來jar file 中template\jquery\下,複制:head.ftl到自己專案中,再修改需要變動的內容。
留言
發佈留言