2013-09-04 4 views
0

jsp 페이지에서 x, y라는 두 개의 strut2 Jquery 자동 완성 상자가 있습니다. 내가 x를 변경하면 자동으로 y도 x의 선택된 값에 따라 변경되어야합니다. struts dojo 태그에서 나는 리로드 주제를 사용하여 다시로드합니다. 하지만 strut2 jquery 다시로드 할 수 없습니다.struts2-jquery 자동 완성 X를 다른 struts2-jquery 자동 완성 Y에서 선택한 값으로 다시로드하는 방법 Y

내 코드

   <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" 
       /> 

답변

0

당신은 당신이 할 수있는 하나의 목록에 json으로 Autocompleter에를 선호하는 경우 :

onSelectTopics="/mapNameListChange" 

에 대한 정의와 같은 특정 값의 첫 번째의 onSelectTopics 정의를 두 번째

listenTopics="/mapNameListChange" 
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); 
    } 

는 그런 다음 결과를 필터링하여 JSON 호출의 PARAM으로 얻을 수있는 extraparameter을해야합니다 다른 함수에게 있습니다

$.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); 

:

같은 함수를 만들 수 있습니다.