I have a form that I then set up the binding as such:
...
private TextField city = new TextField("City");
...
binder.forField(city)
.withValidator(new StringLengthValidator("Must be no longer than 32 characters.", 0, 32))
.bind("city");
...
The binding works and will notify the UI if it is invalid.
How do I programatically tell if the city is currently valid in the code? What I’m trying to accomplish is to disable a save button if there are any invalid form field values. I attempted to do so by adding a value change listener and then checking to see if there’s an error message on the field. This doesn’t work because the listener fires before the bound validator validates and only reports the previous states error, not the current state. I already wired a validator, and some fields are expensive containing data lookups, so I do not want to run validation twice on every field.
In Vaadin 8, how do I disable a save button if any of the fields are not valid?