Anton,

You could perhaps store a reference to the object (row) being edited when
the row editor is opened, allow the editor to function as normal, and then
perform the persistence side of things once it has closed, using the
reference to the object (row) you saved beforehand.

That way you shouldn't need to worry about the underlying data model, or the
selection state of the TableView itself.

Just grab the row from the TableView in beginEdit()
http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/content/TableViewRowEditor.html#beginEdit(org.apache.pivot.wtk.TableView,
int, int)

Chris

On 19 April 2011 01:43, anton dos santos <[email protected]> wrote:

> 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