4 Replies Latest reply on Jun 11, 2010 5:07 AM by ilya_shaikovsky

    How to stop a4j:poll call h:datatable value method?

    spaska

      Hi, My problem is that a4j:poll calls the rich:dataTable value method although I have not set it in the reRender a4j:poll attribute.

      The content of the h:dataTable doesn't really change, which is OK, but calling the value method is a big performance overhead for me. I would like this method to be called only once when the page is first open but not on every poll request.

       

      Here is my jsf:

       

           <a4j:region>
              <h:form id="pollform">
                  <a4j:poll reRender="outputA" interval="2000" id="poll" enabled="true" />
              </h:form>
          </a4j:region>

          <h:form id="mainform">
              <h:panelGroup id="outputA">
                  <h:outputText value="operationA=#{testPollAction.operationA}"  />
              </h:panelGroup>
              <br/>
              <rich:panel id="outputB">
                  <h:outputText value="operationB=#{testPollAction.operationB}"  />
              </rich:panel>
              <rich:dataTable value="#{testPollAction.tableData}" var="record">
                  <rich:column>
                      <h:outputText value="#{record}"></h:outputText>       
                  </rich:column>
              </rich:dataTable>
          </h:form>

       

      and my backing bean in request scope:

       

      public class TestPollAction {
          public String getOperationA(){
              System.out.println("TestPollAction.operationA()");
              return "myA:" + new Date();
          }
         
          public String getOperationB(){
              System.out.println("TestPollAction.opearaionB()");
              return "myB" + new Date();
          }
         
          public List<String> getTableData(){
              System.out.println("TestPollAction.getTableData()");
              List<String> arrayList = new ArrayList<String>();
              arrayList.add(new Date().toString());
              return arrayList;
          }
      }

       

      On every poll I have the following written on the server output:

      INFO: TestPollAction.operationA()
      INFO: TestPollAction.getTableData()

       

      As you can see the operationB() method is not called by poll request. I suppose that getTableData() is called because a value method of a table?

      Interesting if I switch from rich:dataTable to h:dataTavle the getTableData() is invoked 4 times on a poll request.

      Am I doning something wrong? How can I fix this?