2 Replies Latest reply on Dec 8, 2011 3:58 AM by jerome.leveille

    rich:extendeddatatable get selected row problem

    jerome.leveille Newbie

      Hi,

       

      I need your help.

      I begin with richfaces and i have a problem with the rich:extendeddatatable component.

      I would like to be able to get the selected row in the datatable (the selectionMode is 'single') but i only get the first row and not the others.

      I have followed the example on the demo site of richfaces but i don't have the same result.

      I use jsf 2.0 and richfaces 4.0.0.

       

      Here is my code in my xhtml page :

      <rich:extendedDataTable id="myTable" style="width:545px" selectionMode="single" value="#{myBean.myList}" var="myVar" selection="#{myBean.selection}">

           <a4j:ajax execute="@form" event="selectionchange" listener="#{myBean.MyListener}" render="myPanel"/>

      ...

      </rich:extendedDataTable>

       

      Here is my code in my bean :

      @ManagedBean(name="myBean")

      @RequestScoped

      public class MyBean {

           private Collection<Object> selection;

       

           public Collection<Object> getSelection() {

                return this.selection;

           }

           public void setSelection(Collection<Object> selection) {

                this.selection = selection;

           }

       

            public void MyListener(AjaxBehaviorEvent behaviorEvent) {

                UIExtendedDataTable extendedDataTable = (UIExtendedDataTable)behaviorEvent.getComponent();

                Object originalKey = extendedDataTable.getRowKey();

       

                for (Object selectionKey : this.getSelection()) {

                     extendedDataTable.setRowKey(selectionKey);

                     if (extendedDataTable.isRowAvailable()) {

                          some actions ...

                     }

                }

                extendedDataTable.setRowKey(originalKey);

           }

      }

       

      Thanks for your help.