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

    ScrollableDataTable. Selection issue.

    buttau

      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:

      "start_index_1,end_index1;start_index_2,end_index_2;start_index_3,end_index_3;x"

      you could save it in a form:

      "start_rowkey1,end_rowkey1,range_size1;start_rowkey2,end_rowkey2,range_size2"

      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.