0 Replies Latest reply: Jan 31, 2013 3:05 AM by Tshifhiwa RSS

    return two values from autosuggest

    Tshifhiwa
      hi i have inputtext with autosuggest,i what to return two values when i select the values for example if i select cityname i must return cityname and citypostacode for that city.this is how i did my inputtext autosuggest
      <af:inputText label="#{bindings.Cityname.hints.label}" columns="20"
                                              maximumLength="#{bindings.Cityname.hints.precision}"
                                              id="itc4" simple="true"
                                            value="#{pageFlowScope.orgDetailsBean.addressBean.city}"
                                            partialTriggers="it19" autoSubmit="true"
                                            shortDesc="Enter City Name Or Click Refresh To re-enter City Name">
                                  <af:autoSuggestBehavior suggestedItems="#{pageFlowScope.addressbean.oncitySuggest}"/>
                              <af:autoSuggestBehavior/>
                            </af:inputText>
      
          public List oncitySuggest(String searchCityName) {
          ArrayList<SelectItem> selectItems = new ArrayList<SelectItem>();
              searchCityName = searchCityName.toUpperCase();
          System.out.println(searchCityName);
          //get access to the binding context and binding container at runtime
          BindingContext bctx = BindingContext.getCurrent();
          BindingContainer bindings = bctx.getCurrentBindingsEntry();
          //set the bind variable value that is used to filter the View Object
          //query of the suggest list. The View Object instance has a View
          //Criteria assigned
          OperationBinding setVariable = (OperationBinding) bindings.get("setBind_city");
          setVariable.getParamsMap().put("value", searchCityName);
          setVariable.execute();
          //the data in the suggest list is queried by a tree binding.
          JUCtrlHierBinding hierBinding = (JUCtrlHierBinding) bindings.get("CityViewLOV1");
      
      
          //re-query the list based on the new bind variable values
          hierBinding.executeQuery();
      
          //The rangeSet, the list of queries entries, is of type
          //JUCtrlValueBndingRef.
          List<JUCtrlValueBindingRef> displayDataList = hierBinding.getRangeSet();
      
          for (JUCtrlValueBindingRef displayData : displayDataList){
          Row rw = displayData.getRow();
          //populate the SelectItem list
          selectItems.add(new SelectItem(
          (String)rw.getAttribute("Cityname"),
          (String)rw.getAttribute("Boxcode"),
          (String)rw.getAttribute("Citycode")));
          }
      
          return selectItems;
          }