2 Replies Latest reply on Apr 12, 2013 12:39 PM by Leonid GL

    <a4j:repeat> doesn’t work inside of <rich:dataTable>

    Leonid GL Newbie

      Hi All

       

      I am creating a table with dynamic number of columns. My problem is that the <a4j:repeat> doesn’t work inside of <rich:dataTable>. The code is:

       

       

      <rich:dataTable value="#{dataModel.rows}" var="row" id="table">
           
           <rich:column>
                 <h:outputText value="#{row.feature.value}"/>
            </rich:column>
      
            <a4j:repeat value="#{row.values}" var="entry" id="repeat">
                 <rich:column>
                      <h:outputText value="#{entry.value}"/>
                 </rich:column>
            </a4j:repeat>
      
       </rich:dataTable>
      

       

      The first column is printed as expected but the repeat tag doesn't produce any output at all. I tried to replace it with <c:forEach> what didn't work as well.

       

       

      I’m using richfaces 4.3.0 Final with Jboss AS 6.1.Final

       

      Thank you for any help

       

      The table is refreshed by:

       

      <h:commandButton value="Refresh" id="refresh">
            <f:ajax render="table" listener="#{dataModel.refreshTableListener}"/>
       </h:commandButton>
      
        • 1. Re: <a4j:repeat> doesn’t work inside of <rich:dataTable>
          Christian Peter Expert

          this won't work as far as I know, because the "row" variable isn't available at buildtime. (so it cannot be used with c:forEach either)

           

          Can #{row.values} change per row? Then you would have a different number of colums per row. This makes no sense ;-)

           


          What you can do:

           

           

           

          <rich:dataTable value="..." var="row" >

          ...

          <c:forEach items="#{mybean.availableColsForThisDataModel}" var="col">

          <rich:column>

          <h:outputText value="#{row[col]}"/>

          </rich:column>

          </c:forEach>

           

           

          here mybean.availableColsForThisDataModel must be independet from the datatables "var" attribute since this would not be available on buildtime.

           

           

          to access the actual value for each of these dynamic generated columns, you can use some map-notation:

           

          #{row[col]}

           

          not sure when to initialize this availableColsForDataModel stuff. Probably in the @Create annotated method of the bean. Not trivial. There might be a simpler solution for this. ;-)

           

           

          private List<String> availableColsForDataModel;

           

          public List<String> getAvailableColsForDataModel(){...}

           

           

          @Create

          public void init(){


          availableColsForDataModel = new ArrayList<String>();

           

          .... add all properties of your datamodel as String to this list.

           

          }

           

           

           

          this should work with seam 2.2, jsf 1.2 and rf 3.3.3

          • 2. Re: <a4j:repeat> doesn’t work inside of <rich:dataTable>
            Leonid GL Newbie

            Thank you Christian.

             

            No, row.values can't change per row, the length of all rows is equal.

             

            What do you mean with buildtime, which phase of the jsf life cycle do you mean?

             

            I don't understand why the first column is printed out, the row.features.value  is available but the row.values inside of repeat is not