I have the two strut2 Jquery autocompleter box called x,y in my jsp page. If i change x , then automatically y also should change according to selected value of x.In struts dojo tags i used listen topics to reload . But strut2 jquery not able to reload .
my code
<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"
/>
If you prefer json autocompleter to list one you can do :
define the onSelectTopics of the first on to a specific value like
onSelectTopics="/mapNameListChange"
define for the second
listenTopics="/mapNameListChange"
create a function like :
$.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);
where setJQueryAutocompleterURL is another function
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);
}
Then you will have the extraparameter to get as a param of your json call to filter the result.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.