Binder.readBean adds changedBindings and Binder.hasChanges returns true (8.

Hi Vaadin community,
I found some weird behavior with the Binder in Vaadin 8.2 and need some help or explanations:

I am using and try to use the output of binder.hasChanges() to implement a check for changes on any components to prevent the Navigator to change views. Unfortunately, the return value of binder.hasChanges doesn’t work as expected:




true (expected: false)

Binder.hasChanges javadoc:
Check whether any of the bound fields’ have uncommitted changes since last explicit call to readBean(Object), removeBean(), writeBean(Object) or writeBeanIfValid(Object)}. Unsuccessful write operations will not affect this value.

Looking at the stack, Binder.readBean first clears changedBindings, then values are being set to all binded fields. AbstractField.setValue fires an event with userOriginated=false, but the event still arrives in Binder.handleFieldValueChange and adds a new entry to changedBindings…

Is this a bug or am I missing anything?

In the javadoc, you can find this

After readBean, setBean or removeBean hasChanged should be false.
I don’t know why (don’t check the code) but I think it’s a bug. You should open a issue in github. Perhaps you may create a sample project to reproduce this bug easily.

Thanks for checking Jean-Christophe.

I tried to reproduce the behavior in a sample project, but couldn’t. After some digging, I found two bindings for the same field in my code… Without the second binding, binder.hasChanges works as expected.



Are there any use cases where a binder needs tow bindings for the same field? If not, developers should get an exception when adding a second one (like the one you get when adding a component to an already used field in a gridlayout). Is this worth an issue in github?

Here is some code to reproduce the behavior:

public class MyUI extends UI {

    protected void init(VaadinRequest vaadinRequest) {
        final VerticalLayout layout = new VerticalLayout();

        final RSTextField pojoText = new RSTextField();

        Pojo pojo = new Pojo("Test");
        BeanValidationBinder<Pojo> binder = new BeanValidationBinder<>(Pojo.class);
        binder.bind(pojoText, "property");
        binder.bind(pojoText, "property");
    @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
    @VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
    public static class MyUIServlet extends VaadinServlet {

public class Pojo {
    String property;
    public Pojo(String property) {
        super(); = property;
    public String getProperty() {
        return property;
    public void setProperty(String property) { = property;

I do have same issue with 8.3.2. And funny enough, also I tried to prevent navigation away from view with changes and in addition to close window with change. I don’t have several bindings, so there might be some other conditions also which result same behaviour.