0 Replies Latest reply on Jun 20, 2011 5:00 AM by gonzalad

    extendedDataTable : storing column visibility in database

    gonzalad Apprentice



      I need to store user preferences in database.

      Such preferences include extendedDataTable column visibility and column grouping.

      When the user toggles column visibility or grouping, I want to update its database preferences.

      I use RF 3.3.3.


      I've tried usingthe tableState attribute of extendedDatatable, but it is only a JSON String, so i would need to parse it.

      Is there an easy way to :

      • get the tableState as an easy to maniulate object ?
      • add a server listener which will be called whenever column visibility or grouping is changed ?


      Thanks !



      just using rich:extendedDataTable binding attribute and calling ExtendedDataTableState.getExtendedDataTableState(getExtendedDataTable()) appears to solve the first question, but it seems to me quite counter intuitive. Shouldn't tableState just give an instance of ExtendedDataTableState instead of a String ?


      Sample code :


      Programmatically toggling column (just make sure myAction is always called - i.e. using a seam page action) :


      public void myAction() {

          ExtendedDataTableState lState = getExtendedDataTableState();

          // test : verify c3 column is always hidden

          if (lState.isColumnVisible("c3")) {

                  lState.toggleColumnVisibility(getExtendedDataTable(), "c3");




      private ExtendedDataTableState getExtendedDataTableState() {

                return getChargeClienteleDataTableState().getExtendedDataTableStateObject();



      private UIExtendedDataTable getExtendedDataTable() {

                return getChargeClienteleDataTableState().getExtendedDataTable();



      private ChargeClienteleDataTableState getChargeClienteleDataTableState() {

                return (ChargeClienteleDataTableState) Component.getInstance("chargeClienteleDataTableState");





      Getting access to ExtendedDataTableState :




      public class ChargeClienteleDataTableState {

                private ExtendedDataTableState extendedDataTableObject;

                private UIExtendedDataTable extendedDataTable;



                public UIExtendedDataTable getExtendedDataTable() {

                          return extendedDataTable;




                public void setExtendedDataTable(UIExtendedDataTable extendedDataTable) {

                          this.extendedDataTable = extendedDataTable;




                public ExtendedDataTableState getExtendedDataTableStateObject() {

                          if (extendedDataTableObject==null) {

                                    extendedDataTableObject = ExtendedDataTableState.getExtendedDataTableState(getExtendedDataTable());


                          return extendedDataTableObject;





      JSF code :


      <rich:extendedDataTable var="chargeClientele" value="#{rechercherChargeClienteleAction.dataModel}"


                <rich:column id="c1" label="#{messages['chargeClientele.nom.label']}">





                <rich:column id="c2" label="#{messages['chargeClientele.prenom.label']}">




                <rich:column id="c3" label="#{messages['chargeClientele.userRACF.label']}">