Hi
I just wanted to share the problems I faced trying to persist row in a TableView backed by a sorted list. At the beginning, I was using a non sorted list and captured a change in the displayed data using a listener on the table:

    table.getTableViewRowListeners().add( new TableViewRowListener() {

      @Override
      public void rowUpdated(TableView tableView, int index) {
        saveAction.perform(table);
      }
  }

This works fine, in the action#perform() method, I invoke tableView#getSelectedRow() and pass the object to the persistence layer. Then, I needed to have a sorted list and this didn't work anymore, because with sorted list the TableRowEditor no longer does an update, but does a remove followed by an insert. Quick workaround is to listen to rowInserted() instead of rowUpdated(), my action is invoked but fails, because at that moment the updated item is no longer selected ( currently selection has been lost, because it was removed from the list). It is selected again by the TableRowEditor but too late.

Well, it seems to me that the only possible implementation is to override TableRowEditor#endEdit() and invoke the action at the end. Using TableViewRowListeners on the table to capture changes done by the user is not a good idea because it depends on the data model.
Or maybe a listener could be added to the editor?

Regards
Anton



Reply via email to