4 Replies Latest reply on Feb 8, 2013 3:08 AM by christophe.noel

    Dynamic DataTable are not Sortable




      I'm using Richfaces 4.3.0RC1

      The only solution to create a dynamic datatable (with a variable number of columns, as with <rich:columns> in RF 3.3.3) consists in using JSTL <c:forEach>.

      (columns no more exist,  ui:repeat no yet works for tables)


      In that case, sorting is not working (both with dataTable and extendedDatatable built-in OR usual sorting method).


      Just for illustrating, I'm copying my code here below.


      Is there an alternative ? When is planned the columns or repeat support ?


      Thanks a lot


      <rich:extendedDataTable id="dataTable#{popId}"
                                                                            styleClass="fullWidthTable" var="record" selectionMode="none"
                                                                            rendered="#{(viewer.views[viewer.selectedView].type eq 'TABLE')}"
                                                                            <c:forEach items="#{viewer.getDataOperation.response.fields}"
                                                                                      <rich:column sortBy="#{record[response.getId(fieldName)]}">
                                                                                                <f:facet name="header">
                                                                                                          <h:outputText value="#{fieldName}" />
                                                                                                <h:outputText value="#{record[response.getId(fieldName)]}" />
        • 1. Re: Dynamic DataTable are not Sortable
          Suresh G Newbie

          you have created datatable data in setter & getter methods. Get the dataTable outside of setter & getter methods


          in .xhtml


          <rich:extendedDataTable id="#{dataTable.popId}" var=record>

               <rich:column sortBy="#{ record.Id}">

               <f:facet name="header">
                <h:outputText value="Id" />
                <h:outputText value="#{record.Id}" />




          In Bean

          public List<popIddata> popId= new ArrayList<popIdtdata>();


          public List<PopIddata> getPopId() {

                  return popId;




              public void setPopId(List<PopIddata> popId) {

                  this.popId = popId;



          public String gettingData(){

          popId.add(new popIddata("","","",))




          Call gettingData() where ever data you need.

          • 2. Re: Dynamic DataTable are not Sortable

            Hi Suresh,


            This could be the problem, but records is populated outside the getters / setters.



            public List<ArrayList<String>> getRecords() {
                                return records;
                      public void setRecords(List<ArrayList<String>> records) {
                                this.records = records;
            public DataResponse(
                                          GetDataResponseMessageDocument getDataResponseMessageDocument)
                                          throws Exception {
                                this.parse(); // here !!


            Thanks a lot for your help.

            • 3. Re: Dynamic DataTable are not Sortable
              Suresh G Newbie

              Please Remove c:froEach Tag and then try.

              Still if you are facing same problem, share your code again .xhtml files

              • 4. Re: Dynamic DataTable are not Sortable

                As I said in my initial post, "c:forEach" causes the problem. But this is currently the only way to create dynamic tables.