You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description of the bug
If you bind a field to a bean property with validation annotations, one has to use BeanValidationBinder.bind(String) instead of BeanValidationBinder.bind(ValueProvider, Setter) because the later ones ignores the validation annotations.
If possible, minimal reproducible example
import javax.validation.constraints.Size;
import com.vaadin.data.BeanValidationBinder;
import com.vaadin.data.Binder;
import com.vaadin.ui.TextField;
public class Test {
private TextField textField;
private Bean value;
public static class Bean {
@Size(min = 3)
private String property;
public String getProperty() {
return property;
}
public void setProperty(String property) {
this.property = property;
}
}
public void buildForm() {
Binder<Bean> binder = new BeanValidationBinder<>(Bean.class);
// this works:
// binder.forField(textField).bind("property");
// but not this:
binder.forField(textField).bind(Bean::getProperty, Bean::setProperty);
binder.setBean(value);
}
}
`