2013-12-18 24 views
3

作品(加载列表罚款)工作):Struts2的jQuery插件AutoCompleter并不时选择框=“true”属性添加

<s:url id="countrylist" action="lstcountryaction" /> 
<sj:autocompleter selectBox="true" list="lstcountry" 
    listKey="idcountry" listValue="countryname" label="Country" 
    href="%{countrylist}" name="idcountry" /> 

唯一的区别是所述selectBox属性添加。我错过了什么?我正在使用Struts 2.3.15和Struts2 JQuery Plugin 3.6.1(这两个都相当新近)。

谢谢!

回答

2

使能selectBox=true的Struts2 jQuery autocompleter小部件能够正常工作不应远程加载数据。换句话说属性href="%{countrylist}"是选择框不起作用的罪魁祸首。这两个属性是相互排斥的。您必须在两个选项中进行选择,您可以使用autocompleter作为远程数据的输入框或作为选择框,但不需要远程加载数据,因为它是从valueStack作为正常select标记加载的。

您可以使用selectBoxIcon="true"补充选择框以使窗口小部件平滑显示或在标头标记中使用相应的jQuery主题。试试吧

<sj:autocompleter selectBox="true" selectBoxIcon="true" list="lstcountry" 
    listKey="idcountry" listValue="countryname" label="Country" 
    name="idcountry" /> 

来自struts2 jQuery插件wiki页的example

2

1,因为我看到你already posted on the relative Google Group ...但是,如果事情没有改变。同时,根据this (pretty old, but still open JIRA) comment由插件作者:

与选择框的autocompleter正在与静态名单。在 您的使用案例中,您应该使用<sj:select />标记,并使用 autocomplete =“true”。

<s:url id="remoteurl" action="jsonsample"/> 
<sj:select 
     href="%{remoteurl}" 
     autocomplete="true" 
     id="echo3" 
     name="echo" 
     list="languageObjList" 
     listKey="myKey" 
     listValue="myValue" 
     emptyOption="true" 
     headerKey="-1" 
     headerValue="Please Select a Language"/> 

然后一个<sj:select />emptyOptionautocomplete设置为true可更换为动态选择框<sj:autocompleter />你正在寻找。

随意运行this example too,似乎开箱即用。

相关问题