1 Reply Latest reply on Jan 24, 2009 11:26 PM by Ingo Jobling

    Disturbing observation - why is it needlessly executing code??

    Jerry Jackson Newbie

      I have stumbled onto something potentially disturbing where a method call in my xhtml file, showGroupRemoveColumn() in my example below, is redundantly executing the method in the underlying EntityHome class as can be seen in the log snippet below.


      Can anyone explain this??


      Here's the relevant section from my xhtml file:


      <s:div id="relatedGroups" rendered="#{not empty ticket.groups}">
           <h:form id="relatedGroupsForm" styleClass="edit">
                <rich:panel style="background-color: #DAFF7F;">
                     <f:facet name="header">Group Relationships</f:facet>
                     <rich:dataTable id="groupList" var="group" value="#{ticket.groups}">
                          <rich:column width="4%">
                               <f:facet name="header">Group ID</f:facet>
                               #{group.id}
                          </rich:column>                              
                          <rich:column width="40%">
                               <f:facet name="header">Group Name</f:facet>
                               <s:link view="/GroupEdit.xhtml"
                                value="#{group.name}"
                                   id="edit">
                                    <f:param name="groupId" value="#{group.id}"/>
                                    <f:param name="conversationPropagation" value="none"/>
                               </s:link>
                          </rich:column>
                          <rich:column width="1%" rendered="#{ticketHome.showGroupRemoveColumn()}">
                               <f:facet name="header">Remove From Group</f:facet>
                               <h:commandLink action="#{ticketHome.removeTicketFromGroup(group.id)}" 
                                    onclick="if (!confirm('Are you sure you want to remove this Ticket from Group [ #{group.name} ] ?')) return false">
                                    <h:graphicImage value="/img/b_delete.png" title="Remove this Ticket from Group [ #{group.name} ]"/>
                               </h:commandLink> 
                          </rich:column>                                                                                                       
                     </rich:dataTable>
                </rich:panel>
           </h:form>
      </s:div>



      Here's the relevant method from my EntityHome class:



      public Boolean showGroupRemoveColumn() {
           Integer ticketId = getInstance().getId();
           Integer groupCount = getInstance().getGroups().size();
           log.info("%%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: " + groupCount + " --- " + ticketId);
           return (groupCount > 1);
      }



      Here's the relevant section of output from my log file:


      It starts out with the burst of 10 calls to the method, then it fires off another 28 calls to it shortly afterward. I have observed that the second burst is always 7 times the groupCount value (for example: if groupCount is 7 there would be 49 log entries in the second chunk of them)



      12:50:49,798 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,799 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,800 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,800 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,802 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,802 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,803 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,804 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,805 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,806 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,807 INFO  [STDOUT] Hibernate:                                                                                                                                                      
          select                                                                                                                                                                                  
              user0_.id as id62_,                                                                                                                                                                 
              user0_.created_dt as created2_62_,                                                                                                                                                  
              user0_.email_address as email3_62_,                                                                                                                                                 
              user0_.enabled as enabled62_,                                                                                                                                                       
              user0_.password as password62_,                                                                                                                                                     
              user0_.real_name as real6_62_,                                                                                                                                                      
              user0_.username as username62_                                                                                                                                                      
          from                                                                                                                                                                                    
              prismone_v3.User user0_                                                                                                                                                             
          where                                                                                                                                                                                   
              user0_.username=? limit ?                                                                                                                                                           
      12:50:49,808 INFO  [STDOUT] Hibernate:                                                                                                                                                      
          select                                                                                                                                                                                  
              user0_.id as id62_,                                                                                                                                                                 
              user0_.created_dt as created2_62_,                                                                                                                                                  
              user0_.email_address as email3_62_,                                                                                                                                                 
              user0_.enabled as enabled62_,                                                                                                                                                       
              user0_.password as password62_,                                                                                                                                                     
              user0_.real_name as real6_62_,                                                                                                                                                      
              user0_.username as username62_                                                                                                                                                      
          from                                                                                                                                                                                    
              prismone_v3.User user0_                                                                                                                                                             
          where                                                                                                                                                                                   
              user0_.username=? limit ?                                                                                                                                                           
      12:50:49,811 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,812 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,814 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,816 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,817 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,831 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,832 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,839 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,840 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,841 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,845 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,846 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,849 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,850 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,855 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,859 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,864 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,865 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,866 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,867 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,868 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,871 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,873 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,873 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,875 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,875 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,876 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188                                                                                      
      12:50:49,877 INFO  [TicketHome] %%%%%%%%%%%%%%%%% showGroupRemoveColumn() %%%%%%%%%%%%%%%%%: 4 --- 188