2 Replies Latest reply on Mar 6, 2009 5:42 AM by Susanne Toftgaard

    Reset selection in scrollableDataTable

    Susanne Toftgaard Newbie

      I can't reset the selection in my table after new data.

      I use RichFaces 3.2.2 but I have also tried it in version 3.3.0 and it is the same.

      The following happens:
      1) The user performs a search, which will return a list of data being a property in a managed bean. The list is displayed using a ScrollableDataTable. The managed bean also contains a property for a selected row (SingleSelection). When the page is rendered the first time, the table shows the rows from the List, and there is no selection.
      2) The user selects a row (fx row 3) clicks on a a4j:commandButton to display the row details. The aj4 command button will execute an action method on the managed bean. By a "takeSelection-method" the selected row (nr 3) in my List is found.
      If no rows are selected by mouse-click, the take-selection method returns 0.
      The details are then rendered on the page.
      3) The user can then perform a new search on the same page, which results in an updated List of data. When the table is rendered with the new rows from the List, the selection is apparently not reset.

      How to reset the selected row? I am using approximately 80 scrollable tables in my application and would like a solution applied in one location working for all tables.

      I think it is the table-component in the component-tree that is not being updated.

      I have also tried to reset the selection through an actionListener being executed upon new searches. The action listener sets the selection to null in all ScrollableDataTable instances on the page. This however executes to late in the JSF lifecycle. The selection is transferred to the managed bean during the "Update Model Values" phase.... that is before the action listener executes.

      Any help is appriated, thanks!