2 Replies Latest reply on Jan 12, 2011 5:10 AM by usagi

    How to set row selection on  UIScrollableDataTable

    Eugene Coelho Newbie

      Hi,

      Came across a functionality where in i have to set the row to be shown selected when the UIScrollableDataTable is rendered.

      Details:
      When a new row gets created on the server side i want the table to display the new row and show it as selected in the table when it is rendered.

      Displaying the new data works fine ... but tried the following to set the selection on the server side but was unable to see the row selected when the table is rendered.


      public class RecomListingController {

      private UIScrollableDataTable table;

      private SimpleSelection selection = new SimpleSelection();

      ....
      ....

      /**
      * This gets called after the new row gets created in the code.
      * Trying to set the first row to be selected in the table.
      * Have tried to set each statement in the code and tested it but still
      * Couldnt get the first row selected.
      * Strangley the selection gets cleared because of selection.clear();
      * But none of the later calls do anything at the client side.
      * @param newRecomId
      */
      public void setSelectedRecom(Integer newRecomId) {
      selection.clear();
      selection.addKey(new ScrollableTableDataModel.SimpleRowKey(1));
      table.setSelection(selection);
      table.setRowIndex(1);
      table.setActiveRowKey(new ScrollableTableDataModel.SimpleRowKey(1));
      }

      }

      ---------------------------
      xhtml snippet

      <rich:scrollableDataTable id="recommendationScrollableDataTable"
      width="100%" height="200px"
      value="#{recomListingController.allRecommendations}" var="reco"
      binding="#{recomListingController.table}"
      selection="#{recomListingController.selection}"
      sortMode="multy">

      ----------------------------

      Retrieving the selection on the server works fine but not setting of selection on the server and trying to get it displayed in jsf page that is rendered.

      ---------------------------

      Is there a way to set the selection on the server ? Can anyone provide a snippet to set the selection ?


      Thanks,
      Eugene