8 Replies Latest reply on May 24, 2011 2:06 AM by dasago

    RF4.F How can i save the state of extendedDataTable?

    dasago

      Hi,

       

      how can i save the state of extendedDataTable?

       

      I tried the attribute stateVar but i can't use expression language. I get the following error:

       

      javax.servlet.ServletException: stateVar cannot be EL-expression

          javax.faces.webapp.FacesServlet.service(FacesServlet.java:321)

       

       

      root cause

       

      java.lang.IllegalArgumentException: stateVar cannot be EL-expression

          org.richfaces.component.UIDataAdaptor.setValueExpression(UIDataAdaptor.java:736)

          org.richfaces.component.UISequence.setValueExpression(UISequence.java:283)

          org.richfaces.component.AbstractExtendedDataTable.setValueExpression(AbstractExtendedDataTable.java:198)

          com.sun.faces.facelets.tag.jsf.ComponentRule$ValueExpressionMetadata.applyMetadata(ComponentRule.java:104)

          com.sun.faces.facelets.tag.MetadataImpl.applyMetadata(MetadataImpl.java:77)

        • 1. RF4.F How can i save the state of extendedDataTable?
          snaker

          you must to use rowKeyVar instead of stateVar

           

          staterVar="contVar" - in the table #{contVar.index}

          rowKeyVar="contVar" - in the table #{contVar}

          • 2. Re: RF4.F How can i save the state of extendedDataTable?
            dasago

            Thx for your reply, but when i use rowKeyVar i get the same error:

             

            javax.servlet.ServletException: rowKeyVar cannot be EL-expression

            javax.faces.webapp.FacesServlet.service(FacesServlet.java:321)

            • 3. Re: RF4.F How can i save the state of extendedDataTable?
              ilya_shaikovsky

              any *Var attributes used in order just to define request scoped variable name to which some iteration or some object data will be exposed (like var in the dataTable). It can't be used to store the data. in 3.3.x you should use tableState attribute bound to some Object which will hold the state. in 4.x unfortunatelly there is still not resolved task on that https://issues.jboss.org/browse/RF-10442

              • 4. RF4.F How can i save the state of extendedDataTable?
                dasago

                Thx Ilya,

                 

                i hope this will be implemented soon. Maybe you can add this into the migaration guide? I thought it is implemented because i found nothing there.

                I also miss the following features

                 

                Do you know if it is available in the next release? This is planned for october, isnt it?

                • 5. RF4.F How can i save the state of extendedDataTable?
                  lfryc

                  I encourage you to vote on issues which you would like to have implemented.

                  • 6. RF4.F How can i save the state of extendedDataTable?
                    psh

                    Hi there,

                    I'd also like to vote on the build in Feature, but as I was also working on this Feature I ike to share my working approach, basically quite straight foreward:

                    1. Create a TableState representation class, mine holds a String[] for sorting and a Map<String, String> for col-width.

                    2. State Saving should be straight foreward: get the table component, getAttribute "columnsOrder" and also iterate the children (UIColumn) to get their width.

                    3. Restoring is the little tricky part: In JSF2 we have new special SystemEvents inside render-Response, I hooked into the PreRenderViewEvent for the following reason: On initial requests the viewtree is just constructed inside the render Response and to apply my stored values this is the best fitting point. -> find the component(s) (you might use a visitTree) and you can apply the saved values straight foreward. I restore only on NON-Postback NON-Ajax requests (using the PRG pattern this would be almost only the initial pageload).

                     

                    But with the 4.0.0.Final it seems like the state holding of the columns has changed (I'm not completely sure if this worked in M5) so the width for instance is not stored in the tree but only re-submitted by every ajax request, to save this correctly I either have to resubmit the component onSave or keep the width in some helper structure all the time.

                    Is this state-handling wanted for some reasons or maybe a bug?

                    The reproducer would be: create a page with extendedDataTable, resize 1 or 2 columns (will be ajax resize request to backend) then reload the Page -> the column width would be reset.

                    Is there maybe a open Bug for this?

                    • 7. RF4.F How can i save the state of extendedDataTable?
                      psh

                      Hi dasago,

                      regarding the visibility for columns it seems to work just fine by binding the rendered attrinute. I created a EL-extension isColVisible(stateVar, columnId) that I use there.

                      In the backing bean you might represent a Set<String> with hiddenCols for the stateVar and use contains().

                      You just have to ensure that you also update the columnsOrder when you hide a column - remove the id from there too, as this would cause exceptions on missmatches.

                      For the context menu I just created a "x" link for testing, and showing/hiding it using jQuery directly, facing only the issue how to retrigger this on ajax reloads of the table but did not go into detail here yet.

                      • 8. RF4.F How can i save the state of extendedDataTable?
                        dasago

                        Hi psh,

                         

                        thx for your solutions. I will try it out