0 Replies Latest reply on Apr 3, 2012 7:39 AM by mtranchant

    RF4.2: Dynamic DataTable, with render

    mtranchant

      Hi all,

       

      I am trying to display a rich:DataTable with a variable number of columns and rows.

       

      Here is the use-case

      First, the datatable is empty.

      Then, thanks to the user interface, after some manipulations, 2 lists are populated. There are initialized this way:

       

      List<String> tabHeader = new ArrayList<String>();

      List<List<String>> tabDataList = new ArrayList<List<String>>();

       

      Lists are correctly populated.

       

      My last action re-render a datatable named "table", with this structure :

       

      <rich:dataTable value="#{mainController.view.tabDataList}" var="tabTable" id="table">

           <a4j:repeat rowKeyVar="i" value="#{mainController.view.tabHeader}" var="c">  

                <rich:column>

                       <f:facet name="header">

                              <h:outputText value="#{tabHeader}" />

                       </f:facet>

                       <h:outputText value="#{tabTable[i]}" />

                  </rich:column>

            </a4j:repeat>

      </rich:dataTable>

       

      Unfortunately, nothing is shown.

       

      Meanwhile, I have tried with c:forEach according to this snippet :

       

      <rich:dataTable value="#{mainController.view.tabDataList}" var="dataTable" id="table">

          <c:forEach items="#{mainController.view.tabHeader}" var="c"  varStatus="i">

               <rich:column>

                     <f:facet name="header">

                           <h:outputText value="#{c}" />

                     </f:facet>

                     <h:outputText value="#{dataTable[i.index]}" />

               </rich:column>

          </c:forEach>

      </rich:dataTable>

       

      It works, but, of course, forEach do not allow me to change the number of columns/rows when refreshing.

       

      Any body have a clue to make my datatable well displayed and updatable ?

       

      Regards

      Michael