13 Replies Latest reply on Dec 10, 2010 4:44 AM by bsingh1408

    Pagination ExtendedDataModel Query

    bsingh1408

      Hi,

       

      I have created an PaginationExtendedDataModel class which overrides RichFaces ExtendedDataModel. It is used for server side db pagination, sorting and filtering.

       

      The table is made up of table headers which contain the filters - text boxes and dropdown lists and the table rows which contain the data.

       

      When the table is rendered, it calls the walk method which gets the data from the database, and resets some of the filter data.

       

      The data in the table rows gets rendered correctly, however the data in the filter dropdowns in the header fields does not get reset.

       

      The issue is the getters for filter fields are getting called before the walk method which gets the data from the db, and refreshes the filters lists.

       

      How would I enforce the getters for the filters fields to be called after the walk method and the refresh of the filter lists.

       

      Both are getting called at Phase 6.

       

      Please advise how when the table is rendered the the headers fields get the latest data and also how to rerender other parts of the page.

       

       

      Thanks in advance,

      B.

        • 1. Re: Pagination ExtendedDataModel Query
          bsingh1408

          Since the data is retrieved during the walk method, and the getSerializableModel method is called before the page is rendered. Is it possible to put a trigger in the getSerializableModel method to rerender certain components on the page? Or when the table is rendered, is it possible to trigger to rerendering of other components on the page.

          • 2. Re: Pagination ExtendedDataModel Query
            bsingh1408

            Any HELP will be greatly appreciated. I would essentially like to trigger the re-rendering of certain components on the page after the data is fetched from the DB.( walk method).

            • 3. Re: Pagination ExtendedDataModel Query
              nbelaevski

              Hi,

               

              They are rendered before the table data is requested, so walk(...) is called after them. It's not possible to change order of rendering, so I suggest to improve the model so that it will handle this correctly. 

              • 4. Re: Pagination ExtendedDataModel Query
                bsingh1408

                Hi,

                 

                Also, another issue I have found using PaginationDataModel which gets data from the db for each page is performance. The bulk of the performance hit is in two places:

                 

                1) The walk method, in particular the following section:

                for (T item : items) {
                                    U itemId = getId(item);
                                    wrappedKeys.add(itemId);
                                    wrappedData.put(itemId, item);
                                    visitor.process(context, itemId, argument);
                                }

                for (T item : items) {

                                    U itemId = getId(item);

                                    wrappedKeys.add(itemId);

                                    wrappedData.put(itemId, item);

                                   visitor.process(context, itemId, argument);

                  }

                This code calls isRowAvailable twice for each row, and setRowData and getRowData once for each row. These methods reference a hash map to get data or boolean

                On Solaris 10, this section takes 9 seconds for 200 rows and 18seconds for 400 rows using IE6.

                 

                2) Rendering the richfaces dataTable.

                 

                Is there anything I can do to speed up the visitor process in the walk method.

                I am using richfaces 3.2.2.

                 

                Will Richfaces 4 dataTable be considerablly faster than 3.2.2?

                 

                Thanks in advance,

                B.

                 

                • 5. Re: Pagination ExtendedDataModel Query
                  bsingh1408

                  Hi,

                   

                  Also, the rich:dataTable has 20 columns which use the rendered property. The rendered property calls a method that looks up a HashMap.

                   

                  Any recommendations?

                   

                  Thanks,

                  B.

                  • 6. Re: Pagination ExtendedDataModel Query
                    nbelaevski

                    Hi,

                     

                    As an optimization, you can try removing HashMap and use single field to store data instead of it. BTW, how complex is class used as itemId?

                    • 7. Re: Pagination ExtendedDataModel Query
                      bsingh1408

                      Hi,

                       

                      The getId method just returns the id field from the entity. The enity class has many member attributes ~ 30. I have tried getting the rendered values from fields, which are initialised with the values from the HashMap, first time the methods are called. This has made very little difference. I have also looked at

                       

                      1) Adding @BypassInterceptors on getter methods

                      2) Making the ids on the .xhtml of smaller length

                      3) Upgrading to Seam 2.2.1 and richfaces 3.3.3 with JSF 1.2

                       

                      The performance gains have been small.

                       

                      It seems the big performance improvements will be with Richfaces 4?

                       

                      Any other recommendations?

                       

                      Thanks,

                      B.

                      • 8. Re: Pagination ExtendedDataModel Query
                        bsingh1408

                        Hi,

                         

                        I have tried the various things:

                         

                        1) Prashants blog:- http://javaspecialist.wordpress.com/2010/05/30/performance-tuning-of-seam-jsf-richfaces-for-webapps/

                        2) Tomcat server.xml compression setting.

                        3) Firefox is at least twice as fast as IE6. Unfortunately, clients use IE6.

                         

                        Why is the visitior.process so slow? ... building the component tree?

                        Any other recommendations would be appreciated?

                         

                        Thanks,

                        B.

                        • 9. Re: Pagination ExtendedDataModel Query
                          nbelaevski

                          So, where is the main part of time spent - during server rendering or on the client? Have you measured how long does rendering take (via phasetraker)?

                          • 10. Re: Pagination ExtendedDataModel Query
                            bsingh1408

                            Hi,

                             

                            I have used the PhaseTracker to monitor the JSF LIfecyle.

                             

                            The following activities occur at :

                             

                            BEFORE RENDER_RESPONSE 6

                            1) The DB activity to get the data takes  less than 0.4s

                            2) The walk visitor process on the server takes 1s-10s dependent data volume and environment.

                             

                            AFTER RENDER_RESPONSE 6

                            1) Rendering the screen ( client side) takes 1-10s dependent data volume and environment.

                             

                            The richfaces dataTable allows multi selection. Below is a snippet of the dataTable xhtml:

                             

                            <rich:dataTable value="#{eventDataModel}" var="tabledata"
                                                      rows="#{backingBean.rows}" width="100%" rowKeyVar="row"
                                                      reRender="${id}ds" id="${id}table" ajaxKeys="#{backingBean.keys}"
                                                      styleClass="thin_border"
                                                      onRowDblClick="dblClick('#{tabledata.entity.id}')"
                                                      headerClass="table_header" >

                             

                            ....

                             

                            <rich:column width="40px" sortable="false" id="${id}colChk"> 

                             

                            ....


                                <a4j:region id="${id}Chk">
                                    <h:selectBooleanCheckbox id="${id}check" value="#{tabledata.selected}"
                                                             style="text-align:center;">
                                        <a4j:support event="onclick" reRender="listButtonGrid" ajaxSingle="true" limitToList="true" >
                                            <f:setPropertyActionListener value="#{tabledata}"
                                                                         target="#{backingBean.selectedItem}"/>
                                        </a4j:support>
                                    </h:selectBooleanCheckbox>
                                </a4j:region>
                            </rich:column>

                             

                            ...

                             

                            <rich:column sortBy="#{tabledata.id}" filterEvent="onkeyup"
                                         width="#{backingBean.getColumnWidthInt('ID')}" style="width:#{backingBean.getColumnWidthInt('ID')}"
                                         filterMethod="#{eventMgt.activeTable.filters.filterId}"
                                         filterBy="#{tabledata.id}"
                                         title="ID"
                                         rendered="#{backingBean.IDColumnRendered}"
                                         >
                                <f:facet name="header">
                                    <h:outputText value="ID" styleClass="table_header"/>
                                </f:facet>
                                <f:facet name="filter">
                                    <h:inputText value="#{backingBean.filters.id}" onclick="Event.stop(event)"  id="idFilter"
                                                 style="width:#{backingBean.getColumnWidthInt('ID')-10}px" readonly="#{backingBean.selectAll}">
                                        <a4j:support event="onkeyup" reRender="${id}table, ${id}pg, listButtonGrid"
                                                     ignoreDupResponses="true" requestDelay="500" ajaxSingle="true" limitToList="true"
                                                     oncomplete="setCaretToEnd(event);"
                                                />
                                    </h:inputText>
                                </f:facet>
                                <h:outputText value="#{tabledata.entity.id}"
                                              styleClass="#{backingBean.getRowStyleName(tabledata)}" />
                            </rich:column>

                             

                             

                            ....

                             

                            </rich:dataTable>

                             

                            Also, I have not noticed any performance improvements migrating from Seam 2.1.1 to Seam 2.2.1 or from Richfaces 3.3.2 to 3.3.3.

                            Is there any reason that I should migrate to these versions?

                             

                            Thanks,

                            B.

                            • 11. Re: Pagination ExtendedDataModel Query
                              bsingh1408

                              Any update? 

                               

                              Thanks,

                              B.

                              • 12. Re: Pagination ExtendedDataModel Query
                                nbelaevski

                                How many columns do you have? What components are inside them?

                                • 13. Re: Pagination ExtendedDataModel Query
                                  bsingh1408

                                  Hi,

                                   

                                  The table has 20 columns. By default only 8 are rendered. Example of the  dataTable and a column are shown  above. The table is multi select, with db pagination, sorting filtering and each row can be double clicked to go to detail page.

                                   

                                  ...

                                   

                                  <rich:column sortBy="#{tabledata.id}" filterEvent="onkeyup"
                                               width="#{backingBean.getColumnWidthInt('ID')}" style="width:#{backingBean.getColumnWidthInt('ID')}"
                                               filterMethod="#{eventMgt.activeTable.filters.filterId}"
                                               filterBy="#{tabledata.id}"
                                               title="ID"
                                               rendered="#{backingBean.IDColumnRendered}"
                                               >
                                      <f:facet name="header">
                                          <h:outputText value="ID" styleClass="table_header"/>
                                      </f:facet>
                                      <f:facet name="filter">
                                          <h:inputText value="#{backingBean.filters.id}" onclick="Event.stop(event)"  id="idFilter"
                                                       style="width:#{backingBean.getColumnWidthInt('ID')-10}px" readonly="#{backingBean.selectAll}">
                                              <a4j:support event="onkeyup" reRender="${id}table, ${id}pg, listButtonGrid"
                                                           ignoreDupResponses="true" requestDelay="500" ajaxSingle="true" limitToList="true"
                                                           oncomplete="setCaretToEnd(event);"
                                                      />
                                          </h:inputText>
                                      </f:facet>
                                      <h:outputText value="#{tabledata.entity.id}"
                                                    styleClass="#{backingBean.getRowStyleName(tabledata)}" />
                                  </rich:column>

                                   

                                   

                                  ....

                                   

                                  Thanks,

                                  B.