Cancel changes to textfield with binder

The binder works great, it easily makes the interactions I need, but I want to put a discard button to change it.

I have not found a method that can save the original Bean and the Bean changed so that you can cancel any information (cancel button) in the textfields

In the tutorial example, you only have the delete and save button. But what if after changing two columns it quits?

    asSingleSelect().addValueChangeListener(event ->{
            if(event.getValue() != null){

In TextField departament


Instead of setBean method, use readBean and writeBean methods? Then you can have a explicit save button and discard just reads the original bean (you must keep reference to it). I haven’t found any other way to implement buffering in Vaadin 8. Please let me know if you come up with some better solution.

Yes, but we lost the automation of the grid with the textfields, that’s bad.

The problem of using Read and Write and reading the resulting Bean is already a reference to the binder itself, so the change made in Textfield already propagates to the Bean class that receives Read and Write

Yes, it is true that the previously completely automated buffering is lost (or I can’t alteast figure out how to do it). But using readBean and writeBean (or writeBeanIfValid) works without propagating the changes to bean. In grid selection change you need to store the reference to the bean and in onCancel you do binder.readBean(currentBean) and in onSave you call binder.writeBean(currentBean); grid.getDataProvider().refreshItem(currentBean);

This is very frustrating.

There comes a version 8 with good news, we changed our code a lot and in the automated Binder does not even have a cancelChange.

Worse, I have no solution in mind for this problem, because setBean (event.getValue ()) maintains a link to the Grid List object and propagates the changes to all components that are with Binder, but I can not get the Event.getValue then to reset any unwanted changes.

Do I only have users who request to cancel changes that have already started?

If I have to do everything manually, why does it have the new Binder then?

To me removing the coupled buffering from components was a good thing, but I guess it’s a matter of opinion. I understand the relative easyness of using buffering components. Can we maybe figure out a solution for your problem? If you could share some code we could maybe find a solution.

When you navigate through the grid the textField will refresh itself.
When you click the Edit button, editing will refresh the Name in the grid correctly.

But you can not cancel, the textField returns to the original value, but a grid does not. But do not tell me anything in the TextField it updates from a data grid again.

I do not understand this behavior.

return DeportamentModel Bean: private T model;

return Binder: private Tz1Binder binder = new Tz1Binder<>();

In form:

        Tz1TextField txtDepartament = new Tz1TextField("name");

In Grid

        asSingleSelect().addValueChangeListener(event ->{
            if(event.getValue() != null){

In edit button

            try {
            } catch (ValidationException e) {
                // TODO Auto-generated catch block

in cancel button


I think you should use only setBean or readBean+writeBean not setBean+writeBean+readBean.

If you change your grid function to view.getBinder().readBean(event.getValue()); then:

  • No changes will be displayed in the grid before clicking on edit button.
  • You can cancel your changes (readbean(selectedItem in the grid)

If you use setBean then:

  • You don’t need writeBean in edit button.
  • You need to refresh the selected item in the grid from your backend


But in this case you lose the binder with the textField, that is, if the user edit the textField will not be replicated in the grid.

I can not have both worlds, I have to choose, and I do not know why.