|
|
@@ -35,19 +35,18 @@ You can create a field for the name field as you always would: |
|
|
|
[source,java] |
|
|
|
.... |
|
|
|
Person person = new Person("John", 26); |
|
|
|
BeanItem<Person> item = new BeanItem<Person>(person); |
|
|
|
TextField firstName = new TextField("First name"); |
|
|
|
|
|
|
|
TextField firstName = new TextField("First name", |
|
|
|
item.getItemProperty("name")); |
|
|
|
firstName.setImmediate(true); |
|
|
|
setContent(firstName); |
|
|
|
.... |
|
|
|
|
|
|
|
and add the bean validation as a normal validator: |
|
|
|
and bind the field with a bean validation binder: |
|
|
|
|
|
|
|
[source,java] |
|
|
|
.... |
|
|
|
firstName.addValidator(new BeanValidator(Person.class, "name")); |
|
|
|
BeanValidationBinder<Person> binder = new BeanValidationBinder<>(Person.class); |
|
|
|
binder.forField(firstName).bind("name"); |
|
|
|
binder.setBean(person); |
|
|
|
.... |
|
|
|
|
|
|
|
Your `firstName` field is now automatically validated based on the |