8 Replies Latest reply on Oct 29, 2012 7:26 AM by Sanjeev Shrestha

    DYNAMIC COLUMS INTO DATATABLE

    20pippo05 Newbie

      Hi, i have a problem for dynamic columns in a datatable. (i'm using richfaces 4.2)

       

      When return in page, the rows are refresh but the colums doesn't refresh. Why? I also try to replace "ui:repeat" with "a4j:repeat".

      Any suggestion?

      best regards,

      Andrew

       

      *******************

      ***** BEAN  ******

      *******************

      @ManagedBean(name = "anaTerzBean")

      @ViewScoped

      public class MyBean{

       

      private List<LPdv> dataTableListValue;

      private List<LLivelliArticoli> dataTableListColumns

       

       

      public List<CustomObject> getDataTableListValue() {

        return dataTableListValue;

      }

      public void setDataTableListValue(List<LPdv> dataTableListValue) {

        this.dataTableListValue = dataTableListValue;

      }

      public List<CustomObject> getDataTableListColumns() {

        return dataTableListColumns;

      }

      public void setDataTableListColumns(List<CustomObject> dataTableListColumns) {

        this.dataTableListColumns = dataTableListColumns;

      }

       

      public AnaTerzBean() {

      }

       

      public void submit() { 

        /*

        * ROW TABLE

        */

       

        dataTableListValue = x.findByListIdPdv(new Article());

       

        /*

        * COLUMN TABLE

        */

        List<CustomObject> dataTableColumnsTable = article.findByExample(new Article());

        for (LLivelliArticoli column : dataTableColumnsTable) {

        dataTableListColumns.add(column);

        }

        }

      }

       

       

      ****************************

      ******* PAGE JSF ********

      ****************************

      <a4j:commandButton id="cerca" value="Cerca" execute="@form"

                                                        render="tableData" action="#{myBean.submit}" />

       

       

      <rich:dataTable id="tableData"          value="#{anaTerzBean.dataTableListValue}" var="dataItem">

                <f:facet name="header">

                               <h:outputText value="Anagrafica terzializzati" />

                </f:facet>

                <rich:column width="50px">

                               <f:facet name="header">Codice</f:facet>

                               <h:outputText value="#{dataItem.pdvCdPdv}" />

        </rich:column>

        <rich:column width="300px">

                               <f:facet name="header">Descrizione</f:facet>

                               <h:outputText value="#{dataItem.pdvDesPdv}" />

                </rich:column>

                <ui:repeat var="column" value="#{anaTerzBean.dataTableListColumns}">

                          <rich:column width="300px">

                                    <f:facet name="header">

                                              <h:outputText value="#{column.livaCodice}" />

                                    </f:facet>

                          </rich:column>

                </ui:repeat>

                <f:facet name="footer">

                          <h:outputText value="This is the footer" />

                </f:facet>

      </rich:dataTable>