Lexx
Lexx

Reputation: 23

Vaadin 8 Grid EditorSaveListener

In Vaadin 8, given the following Grid definition:

    grid = new Grid<>();
    grid.getEditor().setEnabled(true);
    carBinder = grid.getEditor().getBinder();

with:

    grid.getEditor().addSaveListener(event -> {
    try {
        Binder<Car> binder = event.getSource().getBinder();
        grid.getDataProvider().refreshAll();
    } catch(Exception e) 
        ExceptionNotification.show(e);
    }
    });

The problem I have, I currently cannot access the modified value from the Grid Editor, neither over event.getSource() nor over the binder, defined locally or in class scope.

In the debugger, I see in the Vaadin class com.vaadin.ui.components.grid.EditorImpl a property edited, containing the values, but is private, so not accessible.

The binder.bean value is NULL, in the debug. This would be the value retrieved by: binder.getBean().

So I tried many ways, but currently I could not get the edited value with the save listener, for working with it, and search some help or inspiration for solving the problem.

Upvotes: 2

Views: 1190

Answers (2)

bobsyouruncle
bobsyouruncle

Reputation: 137

I ran into the same issue. After investigating, I've been informed it will be fixed in Vaadin 8.0.3, which is about to be released.

https://github.com/vaadin/framework/issues/8658

Upvotes: 1

Axel Meier
Axel Meier

Reputation: 1127

To get the values use:

binder.writeBean(aCarObject);

According to the documentation it writes the values of the fields into the given object, but throws an exception if any of the fields is invalid.

Upvotes: 1

Related Questions