Skip to content

Update documentation to explicitly mention that JSR-303 annotations won't be used when binding with ValueProvider. #8815

@dve

Description

@dve
  • Vaadin version : 8.0.2
  • 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);
	}
}
`

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions