Vaadin 8 + DataBinding

Hello.

I was trying new Vaadin 8 data binding.

I used BeanBinder and bind 2 TextFields with Validators (lenght > 3 && lenght >5),
Then i added addStatusChangeListener with code from examples:

boolean isValid = !event.hasValidationErrors();
boolean hasChanges = binder.hasChanges();

The problem is when you put first field in wrong state (lenght == 2), put second in wrong state (lenght == 4)
isValid = false (correct)

change second field to correct state (lenght 6), the first one is stil in incorrect state (lenght == 2)
isValid = true (incorrect).

Is this bug (seem to be) or developers need to handle changes and error manually?

Thanks for answer (if).

Hi,

I’m not super-familiar with Vaadin 8 yet, but sounds like the event has the validity value of the most recent changed field. Can you check the validity of the Binder instead?

-Olli

Hello everybody.

So i test the behaviour which i describe above.
Here are some results:

binder.addStatusChangeListener(event -> { boolean isValid = !event.hasValidationErrors(); boolean hasChanges = binder.hasChanges(); }); event contains only errors from actual modified field, not from whole form.


While user is typing something to field, it will trigger status change.

  • is there any way to use logic from V7 - after leaving the field, the value is binded.
  • it is annoing to get error messages while i’m writing and thinking about what to type.


Questions:

is code above a bug or programmer need to find another way to get no valid state of binder

binder.validate().getFieldValidationErrors()

Is there any way to disable “on fly typing + validate” event?

nameTextField.setValueChangeMode(ValueChangeMode.BLUR);
will validate the textfield when the field loses focus.

See https://github.com/vaadin/framework/blob/master/shared/src/main/java/com/vaadin/shared/ui/ValueChangeMode.java

I think default value is LAZY (for TextField).

One big thanks for answer :wink: