在我的jsp页面中有两个名为x,y的strut2 Jquery自动完成器框。如果我更改了x,那么y也应该根据我使用侦听主题重新加载的x.In struts dojo标记的选定值进行更改。但是strut2 jquery不能重新加载。
我的代码
<sj:autocompleter
id="mapNameList"
name="map_name"
list="%{mapNameList}"
selectBox="true"
selectBoxIcon="true"
onChangeTopics="autocompleteChange"
onFocusTopics="autocompleteFocus"
onSelectTopics="autocompleteSelect"
/>
<label for="map_type">MapType: </label>
<sj:autocompleter
id="mapTypeList"
name="map_type"
list="%{mapTypeList}"
selectBox="true"
selectBoxIcon="true"
onChangeTopics="autocompleteChange"
onFocusTopics="autocompleteFocus"
onSelectTopics="autocompleteSelect"
/>发布于 2013-10-11 00:24:41
如果您更喜欢json autocompleter而不是list,您可以这样做:
将第一个on的onSelectTopics定义为一个特定值,如
onSelectTopics="/mapNameListChange"为第二个定义
listenTopics="/mapNameListChange"创建函数,如下所示:
$.subscribe("/mapNameListChange",function(event, data){
//clear the children autocompleters
jQuery('#mapTypeList').val("");
jQuery('#mapTypeList_widget').val("");
var ui = event.originalEvent.ui;
if (ui.item && ui.item.value.length > 0) {
setJQueryAutocompleterURL(jQuery('#mapTypeList_widget'),"your json request", "extraparameter=" + ui.item.value, "the list used in the json", "mapTypeList", "map_type", "/mapNameListChange", "/mapTypeListChange");
};
},null);其中setJQueryAutocompleterURL是另一个函数
function setJQueryAutocompleterURL(widget,href, hrefparameter, list, id, name, selectTopics, listenTopics) {
var options_auto_iban_widget = {};
options_auto_iban_widget.hiddenid = "mapTypeList";
options_auto_iban_widget.selectBox = true;
options_auto_iban_widget.selectBoxIcon= true;
options_auto_iban_widget.forceValidOption = true;
options_auto_iban_widget.onselecttopics = "/autoDebtorIbanChange";
options_auto_iban_widget.list = list;
options_auto_iban_widget.listkey = "id";
options_auto_iban_widget.listvalue = "name";
options_auto_iban_widget.jqueryaction = "autocompleter";
options_auto_iban_widget.id = id;
options_auto_iban_widget.name = name + "_widget";
options_auto_iban_widget.href = href+"?"+hrefparameter;
options_auto_iban_widget.listentopics = "/autoDebtorBicChange";
jQuery.struts2_jquery_ui.bind(widget,options_auto_iban_widget);
}然后,您将拥有要获取的param参数,作为json调用的参数来过滤结果。
https://stackoverflow.com/questions/18608149
复制相似问题