6 Replies Latest reply on Nov 10, 2009 5:23 PM by asookazian

    rich:dataTable always rerender

      Hi all,


      I have one problem which I cannot get rid of it for 3 days. The problem is that in my web page I have 4 tabs and each tab has one rich:dataTable. Every action on whatever component (which is not rich:dataTable), fires rich:dataTable rerender (precisely, calls my method in the model which fills the table), even if parameter

      ajaxSingle="true"

      is set on for example component that has no relation with those tables. So each time some action is triggered I always have 4 redundant select queries (one for each table).


      Here is my code for one of the tables:


                                                              <rich:dataTable id="smsCodeList"
                                                                      value="#{shortCodePage.smsShortCodesList}" var="smsShortCodes"
                                                                      rows="10" reRender="ds">
                                                                      <rich:column sortBy="#{smsShortCodes.pk.code}"
                                                                              filterBy="#{smsShortCodes.pk.code}" filterEvent="onkeyup"
                                                                              width="100">
                                                                              <f:facet name="header">
                                                                                      <h:outputText value="#{messages['shortcode.shortcode']}" />
                                                                              </f:facet>
                                                                              <h:outputText value="#{smsShortCodes.pk.code}" />
                                                                      </rich:column>
                                                                      <rich:column rendered="#{sso.admin}"
                                                                              sortBy="#{smsShortCodes.assignee}"
                                                                              filterBy="#{smsShortCodes.assignee}" filterEvent="onblur"
                                                                              width="200">
                                                                              <f:facet name="header">
                                                                                      <h:outputText value="#{messages['shortcode.assignee_id']}" />
                                                                              </f:facet>
                                                                              <h:outputText value="#{smsShortCodes.assignee}" />
                                                                      </rich:column>
                                                                      <rich:column rendered="#{sso.admin}"
                                                                              sortBy="#{smsShortCodes.assigneeName}"
                                                                              filterBy="#{smsShortCodes.assigneeName}" filterEvent="onblur"
                                                                              width="200">
                                                                              <f:facet name="header">
                                                                                      <h:outputText value="#{messages['shortcode.assignee_name']}" />
                                                                              </f:facet>
                                                                              <h:outputText value="#{smsShortCodes.assigneeName}" />
                                                                      </rich:column>
                                                                      <rich:column sortBy="#{smsShortCodes.status}"
                                                                              filterBy="#{smsShortCodes.status}" filterEvent="onblur"
                                                                              width="100">
                                                                              <f:facet name="header">
                                                                                      <h:outputText value="#{messages['shortcode.status']}" />
                                                                              </f:facet>
                                                                              <h:outputText value="#{smsShortCodes.status}" />
                                                                      </rich:column>
                                                                      <rich:column sortBy="#{smsShortCodes.reservedTo}"
                                                                              filterBy="#{smsShortCodes.reservedTo}" filterEvent="onblur"
                                                                              width="60">
                                                                              <f:facet name="header">
                                                                                      <h:outputText value="#{messages['shortcode.reserved_to']}" />
                                                                              </f:facet>
                                                                              <h:outputText value="#{smsShortCodes.reservedTo}">
                                                                                      <f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss" timeZone="CET"/>
                                                                              </h:outputText>
                                                                              
                                                                      </rich:column>
                                                                      <rich:column sortBy="#{smsShortCodes.validTo}"
                                                                              filterBy="#{smsShortCodes.validTo}" filterEvent="onblur"
                                                                              width="60">
                                                                              <f:facet name="header">
                                                                                      <h:outputText value="#{messages['shortcode.valid_to']}" />
                                                                              </f:facet>
                                                                              <h:outputText value="#{smsShortCodes.validTo}" >
                                                                                      <f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss" timeZone="CET"/>
                                                                              </h:outputText>
                                                                              
                                                                      </rich:column>
                                                                      <rich:column rendered="#{sso.admin}" width="1600px">
                                                                              <f:facet name="header">
                                                                                      <a:commandButton style="margin-left:5px" styleClass="button"
                                                                                              value="#{messages['search']}" />
                                                                              </f:facet>
                                                                              <a:commandButton style="margin-left:5px" styleClass="button"
                                                                                      action="#{shortCodePage.allow('sms', smsShortCodes.pk.code)}"
                                                                                      value="#{messages['shortcode.allow']}"
                                                                                      rendered="#{smsShortCodes.status=='FORBIDDEN'}"
                                                                                      eventsQueue="queue"
                                                                                      reRender="smsCodeList, availableSmsPanel,availableSmsPanelReserve,txtSmsNote" />
                                                                              <a:commandButton style="margin-left:5px" styleClass="button"
                                                                                      action="#{shortCodePage.approve('sms', smsShortCodes.pk.code)}"
                                                                                      value="#{messages['shortcode.approve']}"
                                                                                      rendered="#{smsShortCodes.status=='RESERVED'}"
                                                                                      eventsQueue="queue"
                                                                                      reRender="smsCodeList, availableSmsPanel,availableSmsPanelReserve,txtSmsNote" />
                                                                              <a:commandButton style="margin-left:5px" styleClass="button"
                                                                                      action="#{shortCodePage.block('sms', smsShortCodes.pk.code)}"
                                                                                      value="#{messages['shortcode.block']}"
                                                                                      rendered="#{smsShortCodes.status=='ACTIVE'}"
                                                                                      eventsQueue="queue"
                                                                                      reRender="smsCodeList, availableSmsPanel,availableSmsPanelReserve,txtSmsNote" />
                                                                              <a:commandButton style="margin-left:5px" styleClass="button"
                                                                                      action="#{shortCodePage.restore('sms', smsShortCodes.pk.code)}"
                                                                                      value="#{messages['shortcode.restore']}"
                                                                                      rendered="#{smsShortCodes.status=='BLOCKED'}"
                                                                                      eventsQueue="queue"
                                                                                      reRender="smsCodeList, availableSmsPanel,availableSmsPanelReserve,txtSmsNote" />
                                                                              <a:commandButton style="margin-left:5px" styleClass="button"
                                                                                      action="#{shortCodePage.release('sms', smsShortCodes.pk.code)}"
                                                                                      value="#{messages['shortcode.release']}"
                                                                                      rendered="#{smsShortCodes.status=='BLOCKED' || smsShortCodes.status=='RESERVED'}"
                                                                                      eventsQueue="queue"
                                                                                      reRender="smsCodeList, availableSmsPanel,availableSmsPanelReserve,txtSmsNote" />
      
                                                                      </rich:column>
                                                                      <rich:column rendered="#{!sso.admin}" width="100px">
                                                                              <f:facet name="header">
                                                                                      <a:commandButton style="margin-left:5px" styleClass="button"
                                                                                              value="#{messages['search']}" />
                                                                              </f:facet>
                                                                      </rich:column>
      
                                                                      <f:facet name="footer">
                                                                              <rich:datascroller id="ds" renderIfSinglePage="false"></rich:datascroller>
                                                                      </f:facet>
                                                              </rich:dataTable>
      
      
      



      Can anyone help me?? Its quite urgent...

        • 1. Re: rich:dataTable always rerender
          damianharvey.damianharvey.gmail.com

          Do you have any page actions defined? Maybe to prepare your queries for the page?


          These get called on every ajax Request.


          Other than that, check the scope of the bean that provides the data for the tables and look to increase it (eg to Page or Conversation.)


          Cheers,


          Damian.

          • 2. Re: rich:dataTable always rerender

            No, I dont have any page actions defined. Here is my index.page.xml:


            
            <?xml version="1.0" encoding="UTF-8"?>
            
            <page xmlns="http://jboss.com/products/seam/pages"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd">
                 
               <param name="code"  value="#{shortCodeHome.id}"/>      
               
            </page>
            
            



            also, it is already defined CONVERSATION scope, and when I tried PAGE scope I get the same result.


            Here is my Bean:


            @Name("shortCodePage")
            @Scope(ScopeType.CONVERSATION)
            public class ShortCodePage implements Serializable {
            
            ...
            
                 @SuppressWarnings("unchecked")
                 public List<ShortCodeEntity> getSmsShortCodesList() {
                      System.out.println("getSmsShortCodesList");
                      try {
                           entityManager.clear();
                           if (sso.getAdmin()) {
                                if (smsShortCodeList == null)
                                     return smsShortCodeList = entityManager.createQuery(
                                               "select sc from ShortCodeEntity sc where sc.pk.type=?1 order by sc.pk.code").setParameter(1,
                                               ShortCodeType.SMS).getResultList();
                                else
                                     return smsShortCodeList;
                           } else {
                                if (smsShortCodeList == null)
                                     return smsShortCodeList = entityManager.createQuery(
                                               "select sc from ShortCodeEntity sc "
                                                         + " where sc.pk.type=?1 and (sc.assignee = ?2 or sc.status= ?3) order by sc.pk.code")
                                               .setParameter(1, ShortCodeType.SMS).setParameter(2, sso.getProviderId()).setParameter(3, Status.FREE)
                                               .getResultList();
                                else
                                     return smsShortCodeList;
                           }
                      } catch (Exception e) {
                           FacesMessages.instance().add(Severity.ERROR, e.getMessage());
                           return null;
                      }
                 }
            
            
            



            Please, help...

            • 3. Re: rich:dataTable always rerender
              stefanotravelli

              Take a look at the <aj4:region renderRegionOnly="true"> in the RichFaces documentation.


              You may want to wrap some parts of your template inside this tag in order to avoid table reloading.


              Hope this helps.


              stefano


              • 4. Re: rich:dataTable always rerender
                asookazian

                are you using <rich:tabPanel>?  sounds like the reRendering of components is not being limited to tabs and/or regions...

                • 5. Re: rich:dataTable always rerender

                  Yes, I am using

                  <rich:tabPanel switchType="single">

                  (if I change switchType, the same problem happens also with server and client), all of my components reRender only particular regions, but none of them reRender regions with tables.


                  Arbi, how can I limit reRender to tabs, or does anyone have any other solution?

                  • 6. Re: rich:dataTable always rerender
                    asookazian

                    post this question on the RF forum...