1 Reply Latest reply on Nov 10, 2014 3:40 AM by michpetrov

    Table with dynamic number of data columns?

    lafr

      I'm thinking about using richfaces instead of openfaces in our web application.

      A few times I used <openfaces:dataTable> with <openfaces:columns> which gives a dynamic number of columns, value="#{ }" is pointing to a list here.

      Like in the picture below: first column is fixed, always there. The number of additional columns depends on the number of days given by the user in the selection form before.

      How can I achieve such with richfaces? <rich:dataTable> and <rich:extendedDataTable> seem to be very very flexible, but for this purpose I did not yet find an idea.

       

        • 1. Re: Table with dynamic number of data columns?
          michpetrov

          Hi,

           

          You need to use <c:forEach> to generate a dynamic number of columns, although note that the forEach will not have access to the @var of the table.

           

          <c:forEach var="index" begin="0" end="#{bean.columnsTotal - 1}">
              <rich:column>
                  <h:outputText value="#{row.value}" />
              </rich:column>
          </c:forEach>