2 Replies Latest reply on Jun 17, 2008 1:40 PM by hanafey

    Strange difference between h:dataTable and rich:dataTable

    hanafey

      In the snippet below the panelGroup is not rendered (#{activity.opened} is false). It was expected that bean method #{activity.auditList}, which supplies the dataTable's rows, would not be evaluated. However, the debugger shows that this method is called when there is an ajax submission elsewhere on this page.

      What makes this very strange is that if h:dataTable is substituted with rich:dataTable then #{activity.auditList} is not invoked by ajax requests on the page. Given that the panelGroup in this example is always not rendered, the latter behaviour is expected, but how does one explain the h:dataTable behaviour?

      In this case the unexpected calling of the method in the unrendered part of the component tree caused a subtle bug because the bean was caching results, which emphasizes the need to be able to understand the behaviour of framework. Illogical variants like the above can cause a lot of pain. (btw, the h: components are JSF RI, and view hander is Facelets).

      Any insights will be much appreciated.


      <h:form id="f">
       <rich:simpleTogglePanel id="tog" switchType="ajax" opened="#{activity.opened}" label="#{activity.sectionHeading}"
       immediate="true" ajaxSingle="true" actionListener="#{activity.actionListenerSectionToggle}">
       <h:panelGroup rendered="#{activity.opened}">
       Interval of interest:
      
       <h:selectOneMenu id="hoursAgo" value="#{activity.auditInterval}">
       <f:selectItems value="#{activity.timeIntervalItems}"/>
       <a4j:support event="onchange" reRender="#{id}"/>
       </h:selectOneMenu>
      
       <h:dataTable value="#{activity.auditList}" var="x" styleClass="_table" columnClasses="_ts">
       <!-- h:column definitions omitted -->
       </h:dataTable>
       </h:panelGroup>
       </rich:simpleTogglePanel>
      </h:form>