3 Replies Latest reply on Dec 3, 2008 6:12 AM by Ilya Shaikovsky

    <a4j:support action does not rerender

    Blochaou Blochaou Newbie

      I'm using a4j:support in a <h:selectOneMenu. The components i render in my page depends on the item the user select in the combobox. When the user select an item, i call a function in by backing bean and render the right component. I noticed that <a4j:support call the function but nothing is render in my page. here is my code:

       <rich:panel>
       <f:facet name="header">
       <h:outputText value="#{Bundle.TEXT_INSCRIP}"/>
       </f:facet>
       <div>
       <rich:message showSummary="true" showDetail="false" styleClass="errorMessage" for="registerForm"/>
       </div>
       <h:panelGrid cellpadding="3" width="500px" columns="3">
       <h:outputLabel styleClass="label" value="#{Bundle.NAME}"/>
       <h:inputText id="name" size="30" required="true" value="#{RegisterBackingBean.currentUser.nom}"/>
       <rich:message styleClass="errorMessage" for="name"/>
      
       <h:outputLabel styleClass="label" value="#{Bundle.SURNAME}"/>
       <h:inputText id="prenom" size="30" required="true" value="#{RegisterBackingBean.currentUser.prenom}"/>
       <rich:message styleClass="errorMessage" for="prenom"/>
       <h:outputLabel styleClass="label" value="#{Bundle.USERNAME}"/>
       <h:inputText id="username" size="30" required="true" value="#{RegisterBackingBean.currentUser.userName}"/>
       <rich:message styleClass="errorMessage" for="username"/>
       <h:outputLabel styleClass="label" value="#{Bundle.PASSWORD}"/>
       <h:inputSecret id="password" size="31" required="true" value="#{RegisterBackingBean.currentUser.password}"/>
       <rich:message styleClass="errorMessage" for="password"/>
       <h:outputLabel styleClass="label" value="#{Bundle.PASSWORD_CONFIRM}"/>
       <h:inputSecret binding="#{RegisterBackingBean.secondPassword}" id="passwordConfirm" size="31" required="true"/>
       <rich:message styleClass="errorMessage" for="passwordConfirm"/>
       <h:outputLabel styleClass="label" value="#{Bundle.EMAIL}"/>
       <h:inputText id="email" size="30" required="true" value="#{RegisterBackingBean.currentUser.email}">
       <f:validator validatorId="miwa.emailValidator"/>
       </h:inputText>
       <rich:message styleClass="errorMessage" for="email"/>
       <h:outputLabel styleClass="label" value="#{Bundle.EMAIL_CONFIRM}"/>
       <h:inputText binding="#{RegisterBackingBean.secondEmail}" id="emailConfirm" size="30" required="true">
       <f:validator validatorId="miwa.emailValidator"/>
       </h:inputText>
       <rich:message styleClass="errorMessage" for="emailConfirm"/>
      
      
       <h:outputLabel styleClass="label" value="#{Bundle.COUNTRY}"/>
      
       <h:selectOneMenu value="#{RegisterBackingBean.currentUser.paysidPays}" binding="#{RegisterBackingBean.paysMenu}" id="pays">
       <f:selectItems value="#{RegisterBackingBean.paysItems}"/>
       <f:converter converterId="paysConverter"/>
       <a4j:support event="onchange" action="#{RegisterBackingBean.paysListener}"/>
       </h:selectOneMenu>
      
       <h:outputLabel rendered="false" styleClass="label" value="#{Bundle.REGION}" binding="#{RegisterBackingBean.regionLabel}"/>
      
       <h:selectOneMenu immediate="true" rendered="false" binding="#{RegisterBackingBean.regionMenu}" value="#{RegisterBackingBean.currentUser.regionidRegion}" id="region">
       <f:selectItems value="#{RegisterBackingBean.regionItems}"/>
       <f:converter converterId="regionConverter"/>
       <a4j:support event="onchange" immediate="true" action="#{RegisterBackingBean.regionListener}"/>
      
       </h:selectOneMenu>
      
       <h:outputLabel id="departementLabel" binding="#{RegisterBackingBean.departementLabel}" rendered="false" styleClass="label" value="#{Bundle.DEPARTEMENT}"/>
       <h:selectOneMenu rendered="false" binding="#{RegisterBackingBean.departementMenu}" value="#{RegisterBackingBean.currentUser.departementidDepartement}" id="departement">
       <f:selectItems value="#{RegisterBackingBean.departementItem}"/>
       <f:converter converterId="departementConverter"/>
       </h:selectOneMenu>
      
       <h:commandButton action="#{RegisterBackingBean.registerUser}" value="#{Bundle.REGISTER}" />
       </h:panelGrid>
       </rich:panel>
      


        • 1. Re: <a4j:support action does not rerender
          Michael Abele Newbie

          There is nothing rerendered if you do not specify a reRender attribute for for a4j:support tag.

          <a4j:support event="onchange" action="#{RegisterBackingBean.paysListener}" reRender="regionMenu"/>


          assuming that you add an ID attribute to <h:selectOneMenu> like
          <h:selectOneMenu id="regionMenu" ...>


          Check the developer guide for details ...

          • 2. Re: <a4j:support action does not rerender
            Blochaou Blochaou Newbie

            Thanks for answer but i think this is not the problem. I change my code as this but it is not work.

             <rich:panel>
             <f:facet name="header">
             <h:outputText value="#{Bundle.TEXT_INSCRIP}"/>
             </f:facet>
             <div>
             <rich:message showSummary="true" showDetail="false" styleClass="errorMessage" for="registerForm"/>
             </div>
             <h:panelGrid cellpadding="3" width="500px" columns="3">
             <h:outputLabel styleClass="label" value="#{Bundle.NAME}"/>
             <h:inputText id="name" size="30" required="true" value="#{RegisterBackingBean.currentUser.nom}"/>
             <rich:message styleClass="errorMessage" for="name"/>
            
             <h:outputLabel styleClass="label" value="#{Bundle.SURNAME}"/>
             <h:inputText id="prenom" size="30" required="true" value="#{RegisterBackingBean.currentUser.prenom}"/>
             <rich:message styleClass="errorMessage" for="prenom"/>
             <h:outputLabel styleClass="label" value="#{Bundle.USERNAME}"/>
             <h:inputText id="username" size="30" required="true" value="#{RegisterBackingBean.currentUser.userName}"/>
             <rich:message styleClass="errorMessage" for="username"/>
             <h:outputLabel styleClass="label" value="#{Bundle.PASSWORD}"/>
             <h:inputSecret id="password" size="31" required="true" value="#{RegisterBackingBean.currentUser.password}"/>
             <rich:message styleClass="errorMessage" for="password"/>
             <h:outputLabel styleClass="label" value="#{Bundle.PASSWORD_CONFIRM}"/>
             <h:inputSecret binding="#{RegisterBackingBean.secondPassword}" id="passwordConfirm" size="31" required="true"/>
             <rich:message styleClass="errorMessage" for="passwordConfirm"/>
             <h:outputLabel styleClass="label" value="#{Bundle.EMAIL}"/>
             <h:inputText id="email" size="30" required="true" value="#{RegisterBackingBean.currentUser.email}">
             <f:validator validatorId="miwa.emailValidator"/>
             </h:inputText>
             <rich:message styleClass="errorMessage" for="email"/>
             <h:outputLabel styleClass="label" value="#{Bundle.EMAIL_CONFIRM}"/>
             <h:inputText binding="#{RegisterBackingBean.secondEmail}" id="emailConfirm" size="30" required="true">
             <f:validator validatorId="miwa.emailValidator"/>
             </h:inputText>
             <rich:message styleClass="errorMessage" for="emailConfirm"/>
            
            
             <h:outputLabel styleClass="label" value="#{Bundle.COUNTRY}"/>
            
             <h:selectOneMenu value="#{RegisterBackingBean.currentUser.paysidPays}" binding="#{RegisterBackingBean.paysMenu}" id="pays">
             <f:selectItems value="#{RegisterBackingBean.paysItems}"/>
             <f:converter converterId="paysConverter"/>
             <a4j:support event="onchange" reRender="regionLabel,region" action="#{RegisterBackingBean.paysListener}"/>
             </h:selectOneMenu>
            
             <h:outputLabel id="regionLabel" rendered="false" styleClass="label" value="#{Bundle.REGION}" binding="#{RegisterBackingBean.regionLabel}"/>
            
             <h:selectOneMenu id="region" immediate="true" rendered="false" binding="#{RegisterBackingBean.regionMenu}" value="#{RegisterBackingBean.currentUser.regionidRegion}">
             <f:selectItems value="#{RegisterBackingBean.regionItems}"/>
             <f:converter converterId="regionConverter"/>
             <a4j:support event="onchange" immediate="true" action="#{RegisterBackingBean.regionListener}"/>
            
             </h:selectOneMenu>
            
             <h:outputLabel id="departementLabel" binding="#{RegisterBackingBean.departementLabel}" rendered="false" styleClass="label" value="#{Bundle.DEPARTEMENT}"/>
             <h:selectOneMenu rendered="false" binding="#{RegisterBackingBean.departementMenu}" value="#{RegisterBackingBean.currentUser.departementidDepartement}" id="departement">
             <f:selectItems value="#{RegisterBackingBean.departementItem}"/>
             <f:converter converterId="departementConverter"/>
             </h:selectOneMenu>
            
             <h:commandButton action="#{RegisterBackingBean.registerUser}" value="#{Bundle.REGISTER}" />
             </h:panelGrid>
             </rich:panel>
            

             public String paysListener() {
            
             this.regionLabel.setRendered(false);
             this.regionMenu.setRendered(false);
             this.regionItems.clear();
             this.departementItem.clear();
             this.departementLabel.setRendered(false);
             this.departementMenu.setRendered(false);
             this.currentUser.setRegionidRegion(null);
             this.currentUser.setDepartementidDepartement(null);
            
             if (this.getPaysMenu().getSubmittedValue() != null) {
             Pays ps = paysFacade.findByname((String) this.getPaysMenu().getSubmittedValue());
             if (ps != null) {
             this.currentUser.setPaysidPays(ps);
             if (ps.getHasRegion()) {
             this.regionLabel.setRendered(true);
             this.regionMenu.setRendered(true);
             List<Region> regionList = regionFacade.getByPays(ps.getIdPays());
             for (Region rg : regionList) {
             this.regionItems.add(new SelectItem(rg, rg.getDesignation()));
             }
             }
             }
             }
             return null;
            
             }
            Thanks
            


            • 3. Re: <a4j:support action does not rerender
              Ilya Shaikovsky Master

              make support ajax single in order no to submit the second one which depends on the first. The article about this already present at wiki.