3 Replies Latest reply on Jan 4, 2011 5:24 AM by Ilya Shaikovsky

    ValueChangeListener is refreshing the page

    Anil Kumar Newbie

      Hi All,

       

           We have a typical scenario where we need to display a selectOneMenu based on the value of another selectOneMenu. The valueChangeListener in a selectOneMenu enables the flag to display other dropdowns. Which we need to make ajaxbased using ajax4JSF following is the code snippet of JSP and backingBean. Now when we change the value in first selectOneMenu complete page is getting refreshed displaying second selectOneMenu How can we do this ajax based so that only second selectOneMenu component is loaded instead of refreshing the complete page.

      <a4j:region id="stat1" renderRegionOnly="true" immediate="true">
      <h:panelGroup id="dialToneId">
            <h:outputText value="#{diagmsg.qn_is_dialTone_present}" styleClass="subHeaderBoldBlue"/><f:verbatim><br/></f:verbatim>
                  <h:selectOneMenu id="dialTone" value="#{test.dvalue}"
                           styleClass="inputText11px" valueChangeListener="#{test.doDValueChange}"                  immediate="true">
                          <a4j:support event="onchange" ajaxSingle="true" reRender="dFaultId" ></a4j:support>
                           <f:selectItems value="#{test.itemsList}"/>
                   </h:selectOneMenu>
      </h:panelGroup>
      
      
      
      
      <h:panelGroup id="dFaultId" rendered="#{test.isDPresent == 'Yes'}">
      
             <h:selectOneMenu id="iptvFault" value="#{test.iptvValue}" onchange="submit()" binding="#{test.nextValueSelectItem}" 
      styleClass="inputText11px" valueChangeListener="#{test.doIptvValueChange}" immediate="true">
               <f:selectItems value="#{test.voipList}"/>
              </h:selectOneMenu>
      </h:panelGroup> 
      </a4j:region>

       

       

         public void doDValueChange(ValueChangeEvent valueChangeEvent) {
              try {
      
      
                  this.setIsDialTonePresent((String) valueChangeEvent.getNewValue());
      
                  addPanelGroupId("dialToneId");
                  addPanelComponentIdToMap("dialTone", "UISelectOne", "dialToneId");
      
                  if ((this.getIsDialTonePresent() != null) && (!this.getIsDialTonePresent().trim().equals("")) && (this.getIsDialTonePresent().equalsIgnoreCase(RT004Constants.OPTION_YES))) {
                      addPanelGroupId("dFaultId");
                      addPanelComponentIdToMap("iptvFault", "UISelectOne", "dFaultId");
                  }
      
      
      
      
              } catch (Exception e) {
                  this.handleException(e);
              }
          }