In Vaadin 7 I have PasswordField and following code:-
PasswordField passwordField = new PasswordField((String) processConfig.get("name"));
passwordField.setWidth("100%");
passwordField.addValidator(new RegexpValidator("[^\\s]*", "Whitespace is not allowed for password field"));
Recently I upgraded to Vaadin 8. Now there is compiler error no addValidator method. I know there is new Validator + Binder. But is there any way to avoid Binder and try to have my own validation?
This is one of the differences between Vaadin 7 and Vaadin 8 and subsequent versions like Vaadin 14 for example. In Vaadin 8 Validators are not bound to Fields, but Binder
. Hence if you want to validate single field without using Binder
, the correct way is to use addValueChangeListener(..)
and check the value in ValueChangeEvent
.