5 Replies Latest reply on Feb 13, 2009 11:40 AM by Nick Belaevski

    Rerender datatable (all bean methods are called)

    Matjaz Muhic Newbie

      Well, I tried many options but all options failed me I guess.

      When I request the datatable to be rerendered (either in jsFuncion or click on button) the bean methods are called for filling the table. But the proble is that I have 7 datatables and all get methods are called, instead of just the one that belongs to the datatable that will be rerendered.

      Here's some code:


      My bean:

      public class AgentsBean
      {
       private List<Agent> agentsList;
      
       .
       .
       .
      
       public List getStatusList() {
       return retriveStatus();
       }
      
      }
      



      JSP:
      <a4j:form ajaxSubmit="true">
       <a4j:commandLink reRender="agentsStatusTable" action="#{agentsBean.getAgentsList}">
       <h:outputText value="Rerender agentsStatusTable"/><br/>
       </a4j:commandLink>
      </a4j:form>
      
      <h:panelGrid columns="1">
       <rich:dataTable id="agentsStatusTable" value="#{agentsBean.statusList}" var="as">
       <f:facet name="header">
       <h:outputText value="Agents status"/>
       </f:facet>
       <rich:column styleClass="STATUS_1001" width="60">
       <f:facet name="header">
       <h:outputText value="OK" />
       </f:facet>
       <h:outputText value="#{as.numStatusOk}" id="statusOk" />
       </rich:column>
       <rich:column styleClass="STATUS_1002" width="60">
       <f:facet name="header">
       <h:outputText value="Error" />
       </f:facet>
       <h:outputText value="#{as.numStatusErr}" id="statusErr" />
       </rich:column>
       <rich:column styleClass="STATUS_1003" width="60">
       <f:facet name="header">
       <h:outputText value="Unreachable" />
       </f:facet>
       <h:outputText value="#{as.numStatusUnr}" id="statusUnr" />
       </rich:column>
       </rich:dataTable>
      </h:panelGrid>
      


        • 2. Re: Rerender datatable (all bean methods are called)
          Matjaz Muhic Newbie

          I tried few workarounds and it still doesn't work, or maybe I'm do it wrong?

          Here's my new code:

          <h:form id="agentsStatusForm">
           <h:commandButton value="Rerender 1">
           <a4j:support event="onclick" reRender="agentsStatusForm" />
           </h:commandButton>
           <a4j:keepAlive beanName="agentsBean"/>
           <rich:dataTable id="agentsStatusTable" value="#{agentsBean.statusList}" var="as">
           <f:facet name="header">
           <h:outputText value="Agents status"/>
           </f:facet>
           <rich:column styleClass="STATUS_1001" width="60">
           <f:facet name="header">
           <h:outputText value="OK" />
           </f:facet>
           <h:outputText value="#{as.numStatusOk}" id="statusOk" />
           </rich:column>
           <rich:column styleClass="STATUS_1002" width="60">
           <f:facet name="header">
           <h:outputText value="Error" />
           </f:facet>
           <h:outputText value="#{as.numStatusErr}" id="statusErr" />
           </rich:column>
           <rich:column styleClass="STATUS_1003" width="60">
           <f:facet name="header">
           <h:outputText value="Unreachable" />
           </f:facet>
           <h:outputText value="#{as.numStatusUnr}" id="statusUnr" />
           </rich:column>
           </rich:dataTable>
           </h:form>
          
           <h:form id="processOSStatusFormFord">
           <h:commandButton value="Rerender 1">
           <a4j:support event="onclick" reRender="processOSStatusFormFord" />
           </h:commandButton>
           <a4j:keepAlive beanName="processesBean"/>
           <rich:dataTable id="processOSStatusTableFord" value="#{processesBean.processesOSListFord}" var="p">
           <f:facet name="header">
           <h:outputText value="Ford"/>
           </f:facet>
           <rich:column styleClass="#{p.status}">
           <f:facet name="header">
           <h:outputText value="Description" />
           </f:facet>
           <h:outputText value="#{p.description}" id="p" />
           </rich:column>
           <rich:column styleClass="#{p.status}">
           <f:facet name="header">
           <h:outputText value="Value" />
           </f:facet>
           <rich:progressBar styleClass="rsProgressBar" mode="client" value="#{p.value}" label="#{p.value}" minValue="0" maxValue="100"/>
           </rich:column>
           </rich:dataTable>
           </h:form>
          


          • 3. Re: Rerender datatable (all bean methods are called)
            Ilya Shaikovsky Master

            look

            <a4j:form ajaxSubmit="true">
             <a4j:commandLink reRender="agentsStatusTable" action="#{agentsBean.getAgentsList}">
             <h:outputText value="Rerender agentsStatusTable"/><br/>
             </a4j:commandLink>
            </a4j:form>
            

            and
             <h:commandButton value="Rerender 1">
             <a4j:support event="onclick" reRender="agentsStatusForm" />
             </h:commandButton>
            


            causes me to think that I should point you to documents from the beginning. We couldn't tell about RF case before the basics used wrong.

            1) no need in ajaxSubmit=true form if you using a4j:controls inside
            2) using support inside h:command causes two requests to be fired in the same time. And full page reloading is normal in this case.

            • 4. Re: Rerender datatable (all bean methods are called)
              Matjaz Muhic Newbie

              Well, there's not many resources on richfaces. Can someone give me a working example for datatable?

              Thank you!

              • 5. Re: Rerender datatable (all bean methods are called)
                Nick Belaevski Master

                Hello,

                Wrap each dataTable into

                <a4j:region renderRegionOnly="true">
                that is the workaround.