0 Replies Latest reply on Jan 30, 2009 10:00 AM by lukas.eder

    datascroller does not work correctly if multiple instances o

    lukas.eder

      I have experienced a problem with the datascroller, when it is used in combination with tables that appear on several places with the same ID. This is roughly what I want to do:

      main.jsp:

      <h:panelGroup id="all">
      <rich:tabPanel>
       <rich:tab>
       <rich:datascroller for="table" reRender="all"/>
       <a4j:include viewId="/sub.jsp" />
       </rich:tab>
       <rich:tab>
       <rich:datascroller for="table" reRender="all"/>
       <a4j:include viewId="/sub.jsp" />
       </rich:tab>
      </rich:tabPanel>
      </h:panelGroup>


      sub.jsp:
      <rich:dataTable id="table">
      [...]
      </rich:dataTable>


      When using the datascroller on the second tab, it will update the contents of the first tab, even if it displays the paging of the second one.

      Now I know that my problem is resolved when I put the datascrollers within the dataTable themselves:

      <rich:dataTable>
       <f:facet name="header">
       <rich:datascroller for="table"/>
       </f:facet>
      [...]
      </rich:dataTable>


      But I have several cosmetic reasons why I want to put the scroller outside the table structure. Also, I could duplicate sub.jsp so that different ID's are possible. But that would be annoying, as the two tabs' contents are very similar in structure.

      I have found the problem in this method:

      UIComponent org.ajax4jsf.renderkit.RendererUtils.findComponentFor(UIComponent, String):
      
      // Lines 876-880
      while (null == target && null != parent) {
       target = parent.findComponent(id);
       root = parent;
       parent = parent.getParent();
      }


      It is the UIComponent.findComponent(String) method marked in red that will not go look within the <a4j:include /> tags as specified, because <a4j:include /> is a NamingContainer. The funny thing is, a couple of lines below the correct method to use was implemented by the ajax4jsf people:

      if (null == target) {
      target = findUIComponentBelow(root, id);
      }


      This code explains, why in the end, the first tab is updated

      I am using JSF 1.2.12 and RichFaces 3.3.0 GA on Tomcat 6.0.16