1 Reply Latest reply on May 12, 2009 5:10 PM by Nikos Paraskevopoulos

    Skipping row in h:panelGrid

    Jon Kleiser Newbie
      I have a view with a <h:panelGrid columns="3"> with four rows of labels/values. Based on some boolean conditions, some of the rows shall not be rendered. I know I can skip an entire row by putting the same rendered clause on each of the three h:outputText elements in that row, but that doesn't look very elegant or efficient to me. Is there a better solution?
        • 1. Re: Skipping row in h:panelGrid
          Nikos Paraskevopoulos Novice

          Hi,


          Unfortunately JSF doesnt cannot disable the rendering of an entire row either in a dataTable or an UIPanel. My thoughts (how would I do it):


          1) If the number of rows is dynamic, i.e. they come from a collection, then expose (bean getter, @Out) a filtered view of that collection. The filtered view should contain only the data that should be displayed.


          In that case, you would also preferably use an <h:dataTable> instead of a <h:panelGrid>.


          2) Use Seam's own <s:div> component and specify the rendered attribute. Place your original label/value controls inside the <s:div>. You also get a modern, tableless design for bonus, if you can manage the CSS stuff :) I.e.:


          <s:div id="row1" rendered="#{your.condition1}">
            <h:outputLabel for="c1">C1:</h:outputLabel>
            <h:inputText id="c1" value="#{binding.for.c1}" />
            ...
          </s:div>
          <s:div id="row2" rendered="#{your.condition2}">
          ...etc...