3 Replies Latest reply on Aug 24, 2009 2:24 PM by tom til

    Correct behavior of the rendered attribute with a datatable

    Charles Caron Newbie

      Let's take a look at this simple fragment of page :


      <h:dataTable  value="#{projectList.resultList}" var="project" rendered=" #{projectList.resultCount > 0}">
          <h:column>
           <h:outputText value="#{project.manager}"/>
          </h:column>
      </h:dataTable>
      



      The projectList variable is an EntityQuery object. Using some classes from this post (great tool to measure performance of your application by the way !), i found that some methods get called more than once for apparently no reason :


      
      31.55389 ms7   EntityQuery.getResultCount()
      
      8.847945 ms1   EntityQuery.getResultList()
      
      5.13022 ms1   EntityQuery.validate()
      



      Maybe someone here has already experienced similar behavior with EntityQuery or EntityHome objects ? When you have a large view with many components using the rendered attribute and the same method gets called 100 times or more, it may be a problem...


      Thanks,


      Charles

        • 1. Re: Correct behavior of the rendered attribute with a datatable
          tom til Newbie

          Hi, i experiment the same bug, and it's really bored...



                              <s:div style="float:left;margin:15px;" id="div1">
                                        <s:link view="/admin/societie.xhtml"  border="0"
                                                id="bt1"  rendered="#{bean.canSomething()}" >
                                                                                  
                                             <h:graphicImage value="/test.png"
                                                  style="border:0px" />
                                             <h:outputText
                                                  value="#{language.getText('accueil.societiesManagement')}"
                                                  style="display:block;" />
                                        </s:link>
                                   </s:div>





               public boolean canSomething() {
                    valueOfHell++;
                    System.out.println("debut canSomething...."+valueOfHell);
          
          
                    if (valueOfHell==2){
                         System.out.println("je retourne FAUX");
                         return false;
                    }
          
                    System.out.println("fin canSomething...."+valueOfHell);
                    return true;
               }





          i declare valueOfHell in static way....my class in on scopetype equal scope.SESSION


          so why, i have 5 call of canSomething ?
          if i try 'to hack' and return true value if i'm on the second calling, no way



          it's really a big bug i guess, not acceptable for a framework like seam...i wanna a patch, i'm sure we're not alone in this case

          • 2. Re: Correct behavior of the rendered attribute with a datatable
            tom til Newbie

            on my console i have...




            13:55:53,177 INFO  debut canSomething....1
            13:55:53,177 INFO  fin canSomething....1
            13:55:53,178 INFO  debut canSomething....2
            13:55:53,178 INFO  fin canSomething....2
            13:55:53,178 INFO  je retourne FAUX
            13:55:53,180 INFO  debut canSomething....3
            13:55:53,180 INFO  fin canSomething....3
            13:55:53,181 INFO  debut canSomething....4
            13:55:53,181 INFO  fin canSomething....4





            SO, i never see something like that


            this pb occur a real performance problem in my application


            • 3. Re: Correct behavior of the rendered attribute with a datatable
              tom til Newbie


              13:55:53,177 INFO  debut canManageSocieties....1
              13:55:53,177 INFO   fin canManageSocieties....1
              13:55:53,178 INFO   debut canManageSocieties....2
              13:55:53,178 INFO   fin canManageSocieties....2
              13:55:53,178 INFO   je retourne FAUX
              13:55:53,180 INFO   debut canManageSocieties....3
              13:55:53,180 INFO   fin canManageSocieties....3
              13:55:53,181 INFO   debut canManageSocieties....4
              13:55:53,181 INFO   fin canManageSocieties....4