0 Replies Latest reply on Jan 13, 2009 2:58 PM by Buttau Alexander

    ScrollableDataTable. Selection issue.

    Buttau Alexander Newbie

      RichFaces uses indexes of rows to keep selection state on the client side. This causes some problems in a multi-user environment where each user can add or delete data records bound to table.

      For example:

      1. First user calls a page with scrollable data table. 10 rows are shown.
      2. First user selects data row with index 2
      3. Second user deletes a row with index 1
      4. First user submits a form. The row which will be returned on the server side as selection is not the row which was selected by the first user but the row which had an index 3 but got index 2 after second user delete action.

      Conclusion: Selection state should save row keys instead of row indexes.
      And that would be useful if a selection object on the server side would have a flag which indicates if selected range was changed (rows removed or added) outside.

      currently selection state is saved in a form:


      you could save it in a form:


      and check

      if (!exists(start_rowkey1) || !exists(start_rowkey2)
       || range_size1 != getRangeSize(start_rowkey1, range_size2)) {
       // ignore this range and set selection dirty
       selection.dirty = true;

      ... or something like that. It is not 100% correct, it is possible that 1 row was deleted and 1 row was added so that range_size1 still equals getRangeSize(start_rowkey1, range_size2), ... but almost :)
      Probably you have another ideas how to handle these cases.