12 Replies Latest reply on Mar 26, 2010 9:47 AM by babazs

    Datascroller rerenders data table on each ajax request

    bitec

      Hello

      I have a simple dataScroller with no a4j:outputPanel:

      <rich:datascroller align="right" page="#{paymentFilterBean.pageNumber}" for="paymentTable"
       maxPages="10" reRender="sc1" id="sc2" />
      


      and a table:
      <rich:dataTable var="selectedPayment" value="#{paymentBean.entities}" id="paymentTable"
       width="100%" rows="16" >
      ...
      </rich:dataTable>
      


      There is also a link on the page:
      <a4j:region>
       <a4j:commandLink limitToList="true" ajaxSingle="true" id="expenseItem" reRender="expenses_panel" oncomplete="#{rich:component('expenses_panel')}.show()">
       <h:outputText value="#{paymentFilterBean.filterExpense.displayName}" />
      
       </a4j:commandLink>
      </a4j:region>
      


      The problem
      : each time I click the link, the table is rerendered and all data is fetched again. During debuging I found some kind of stack trace during the rerendering phase:

      ....
      HtmlDataTable(UIDataTable).createDataModel() line: 120
      HtmlDataTable(UIDataAdaptor).getExtendedDataModel() line: 621
      HtmlDataTable(UIDataAdaptor).getRowCount() line: 248
      HtmlDatascroller(UIDatascroller).getRowCount(UIData) line: 362
      HtmlDatascroller(UIDatascroller).setupFirstRowValue() line: 452
      RenderPhaseDataScrollerVisitor.afterRoot(PhaseEvent, Object) line: 191
      RenderPhaseComponentListener.beforePhase(PhaseEvent) line: 73
      AjaxViewRoot.processPhaseListeners(FacesContext, PhaseId, boolean) line: 185
      ...


      Also, found that this is a new behavior for RF since 3.2.1 and datascroller refreshes data even when neither it, nor the table is rerendered. It's really confusing.... How can I avoid excess datatable rerenderings and fetching data from database on each ajax calls? The worst thing is when I open the modalpanel with rich:tree. The table is rerendered on every node selection in the tree in the modal panel!!!

        • 1. Re: Datascroller rerenders data table on each ajax request
          ilya_shaikovsky

          Yes, this change was done because of requests of updation messages and outputPanel with auto updates inside the tables. We can't do this without fetching the data. You should add ajaxSingle=true to controls which should not fetch iteration components data on requests.

          And if you have also a problem of fetching all the data with datascroller you should visit richfaces-demo dataTable sample and look through dataModels sample tabs.

          • 2. Re: Datascroller rerenders data table on each ajax request
            bitec

            Thank you Ilya,

            I have ajaxSingle="true", I tried a4j:region also. Seems datascrollerVisitor is called for the whole page in any case.

            Do you mean using SerializableDataModel? The main question about this - which moments will serrialized data be used and which - real db data will be fetched? I'm afraid that each link on the page will produce the postback and seriallized data fetching, although in most moments this is not needed (filters, datascrolling, page refreshes and so on).

            Also it's still very strange, that working in modalPanel and going through tree nodes (for example) produces background table rerendering on each click. There should be the way to avoid datascroller visitor behavior, cause there are a lot of situations, when this is not needed at all.. May be I should try binding for the datascroller and disable it somehow on some conditions and this will prevent visitor behavior?

            • 3. Re: Datascroller rerenders data table on each ajax request
              ilya_shaikovsky

              sorry. seems I proposed wrong attribute :/

              should be limittolist="true" And b.t.w. 3.3.1 GA should be used.

              • 4. Re: Datascroller rerenders data table on each ajax request
                bitec

                Ilya,

                "a4j:commandLink limitToList="true" ajaxSingle="true"" - I use both atributes. The datascroller phase listener rerenders the table anyway.

                And I use the latest version of RF.

                • 5. Re: Datascroller rerenders data table on each ajax request
                  kukeltje

                  There is something strange with using datascrollers. I'm currently trying to make a minimal testcase that demonstrates the problem in more than one way. I've seen the same with switching tabs and even datascrollers triggering other datatables on the same page. If I have a minimal test case, I'll make a new topic in this forum.

                  • 6. Re: Datascroller rerenders data table on each ajax request
                    bitec

                    I don't think you need to create the new topic. Iliya has described the issue and it is described in the tutorial. But seems this implementation contains the bug cause the datascroller rerenders the table on each ajax request, ignoring any a4j:region and ajaxSingle="true" commands.

                    Ilya, may be I should create the Jira task for this?

                    • 7. Re: Datascroller rerenders data table on each ajax request
                      ilya_shaikovsky

                      There is a new problem seems appears. dataScoller uses phaseListener in order to locate it's table and check if the page matches or change required.. And yes.. it calls for dataModel at the time. And in general issue could be created but there is no way to correct this in current branch because of design. Probably we should revise the approach in general for 4.x. The only workaround I see is to make phaseListener which will change rendered property of UIData to false for the requests where table should not be called.

                      • 8. Re: Datascroller rerenders data table on each ajax request
                        nbelaevski

                        BTW, thread name is not correct. While model is evaluated, table is not redrawn.

                        • 9. Re: Datascroller rerenders data table on each ajax request
                          bitec

                          Ok, for those who faces this problem, here is a workaround:

                          <a4j:commandLink...>
                          <f:setPropertyActionListener value="false" target="#{paymentBean.dataScrollerRendered}" />
                          </a4j:commandLink>
                          
                          ....
                          <rich:datascroller for="paymentTable"
                          maxPages="10" reRender="sc2" id="sc1" rendered="#{paymentBean.dataScrollerRendered}"/>
                          


                          By default the property is set to true and datascroller is always rerendered. Each action which need data refetching should set this property to false.

                          • 10. Re: Datascroller rerenders data table on each ajax request
                            bitec

                            Sorry, meant "Each action which DOESN'T need data refetching"... It's a pity, that posts cannot be edited here...

                            • 11. Re: Datascroller rerenders data table on each ajax request
                              ilya_shaikovsky

                              yup.. even simpler that we suggested :) Thanks for update!

                              • 12. Re: Datascroller rerenders data table on each ajax request
                                babazs

                                Hy!

                                 

                                Any improvements  with this bug?

                                 

                                thanks.