4 Replies Latest reply on Sep 18, 2008 4:52 PM by shadowcreeper

    rich:columns within rich:tab bug?

      I have a rich:tabPanel with several rich:tabs, and am using ajax switchType.
      My understanding is that only the active tab should be loading.

      I have found, however, that when I have rich:dataTable that uses rich:columns the backing bean is called to evaluate the values attribute prior to the containing tab ever being selected.

      Here is a very simplified example of my setup:

      <rich:tabPanel selectedTab="#{selectedTabAction.selectedTab}" switchType="ajax">
       <rich:tab label="Tab 1" name="tab1">
       Tab 1 Content Here
       </rich:tab>
      
       <rich:tab label="Tab 2" name="tab2">
       <rich:dataTable value="#{bean.values}" var="_value">
       <rich:columns rendered="#{bean.show}" value="#{bean.cols}" var="_col"/>
       </rich:dataTable>
       </rich:tab>
      </rich:tabPanel>
      


      What I have noticed is that when the page is loaded #{bean.cols} is being called despite the fact that tab 2 is not the active tab. The rendered call #{bean.show} is not called.

      I am not seeing this behavior elsewhere with rich faces components in a tab control - it seems specific to rich:columns.

      Is this a bug or are my assumptions incorrect?

      -Mark


        • 1. Re: rich:columns within rich:tab bug?

          Sorry - my bad.

          I should have read the docs better:


          The <rich:columns> tag is initialized during components tree building process. This process precedes page rendering at "Render Response" JSF phase. To be rendered properly the component needs all it variables to be initialized while the components tree is being building. A javax.servlet.jsp.JspTagException occurs if <rich:columns> uses variables passed from other components, if these variables are initialized during rendering. Thus, when <rich:columns> is asking for such variables they do not already exist. Use <c:forEach> JSP standard tag as workaround.


          • 2. Re: rich:columns within rich:tab bug?
            shadowcreeper

            ok, dumb question, but where is this doc found?

            • 3. Re: rich:columns within rich:tab bug?

              When viewing the online demo you can click the Documentation link.

              Here is the specific link for rich:columns:
              http://www.jboss.org/file-access/default/members/jbossrichfaces/freezone/docs/devguide/en/html/columns.html

              I think there is a problem with the example code for the workaround, however. It doesn't make sense as written. I think it should be:

              <rich:dataTable value="#{bean.data}" var="var">
               <c:forEach items="#{var.columns}" var="col">
               <rich:column>
               ...
               </rich:column>
               </c:forEach>
              </rich:dataTable>
              


              Do I have that right?

              -Mark


              • 4. Re: rich:columns within rich:tab bug?
                shadowcreeper

                No. See: http://www.ilikespam.com/blog/c:foreach-vs-ui:repeat-in-facelets

                Basically, the c:forEach is processed before the rich:dataTable, thus it will not be able to see any var set by the dataTable.

                The individual rich:column should be able to see it though as the c:forEach will have already run creating several rich:column elements which are processed at the same time as the dataTable.

                So, probably something more like this:

                <rich:tab label="Tab 2" name="tab2">
                 <rich:dataTable value="#{bean.values}" var="_value">
                 <c:forEach value="#{bean.cols}" var="_col">
                 <rich:column rendered="#{bean.show}" />
                 </c:forEach>
                 </rich:dataTable>
                </rich:tab>