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?
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);
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.
getModel return DeportamentModel Bean: private T model;
getBinder return Binder: private Tz1Binder binder = new Tz1Binder<>();
In form:
Tz1TextField txtDepartament = new Tz1TextField("name");
addToForm(txtDepartament).bind(DepartamentModel::getName,DepartamentModel::setName);