4 Replies Latest reply on Jan 21, 2010 7:47 AM by fdegrigny

    How to reRender selection after sorting ?

      I am using an extendedDatatable with an a4j:support to refresh the current selected panel. This is OK.

      But when the user sorts the table, the selection no longer match the selected panel (due to rows re-ordring).

      This is very confusing for the end user.

      So what I whant is to clear the current selection or rerender the selected panel, but I don't see how to do that.

      I tried to define the reRender attribute for the table (reRender="selectedPanelId")  : it doesn't work.

      May be there an event handler to be aware when a new sorting is triggered ?

        • 1. Re: How to reRender selection after sorting ?
          ilya_shaikovsky

          demo sources available in SVN repo.

           

          http://livedemo.exadel.com/richfaces-demo/richfaces/extendedDataTable.jsf - works there.

          1 of 1 people found this helpful
          • 2. Re: How to reRender selection after sorting ?

            Ok, the trick seems to be the use of an ExtendedTableDataModel as value instead of the default items list.

            So, I have wrapped my items into a ExtendedTableDataModel like in the example.

            But now I got the following exeption when trying to display the row number with

             

            <rich:column id="col_index" >
                   <h:outputText value="#{pageCtrl.table.rowIndex + 1}" />
            </rich:column>

             

            java.lang.NullPointerException      at org.richfaces.model.ExtendedTableDataModel.getRowIndex(ExtendedTableDataModel.java:206)      at org.ajax4jsf.component.UIDataAdaptor.getRowIndex(UIDataAdaptor.java:311)      at sun.reflect.GeneratedMethodAccessor282.invoke(Unknown Source)      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)      at java.lang.reflect.Method.invoke(Method.java:585)      at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)      at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)      at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:73)      at org.apache.el.parser.AstValue.getValue(AstValue.java:118)      at org.apache.el.parser.AstPlus.getValue(AstPlus.java:38)      at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)      at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)

             

            any ideas ?

            • 3. Re: How to reRender selection after sorting ?

              I have set the rowIndex manually : dataModel.setRowIndex(-1), so there no longer NPE but this value is never updated.

              I still need to display the rowIndex, how I can do that ?

              • 4. Re: How to reRender selection after sorting ?

                At last, I have manage to do this with a custom method in the request bean, as follow :

                 

                public class PageCtrl
                {
                    private HtmlExtendedDataTable table;
                    private Integer rowIndex;

                 

                    public int getRowIndex()

                    {
                        if( rowIndex == null )
                        {
                            rowIndex = table.getFirst();
                        }
                        else
                        {
                            rowIndex = rowIndex + 1;
                        }
                        return rowIndex;
                    }

                 

                //...

                }

                 

                <rich:extendedDataTable id="table" value="#{pageCtrl.dataModel}"binding="#{pageCtrl.table}">

                     <rich:column id="col_index" >   
                         <h:outputText value="#{pageCtrl.rowIndex + 1}" />
                     </rich:column>

                ...

                </rich:extendedDataTabl>