diff options
-rw-r--r-- | documentation/articles/UsingBeanValidationToValidateInput.asciidoc | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/documentation/articles/UsingBeanValidationToValidateInput.asciidoc b/documentation/articles/UsingBeanValidationToValidateInput.asciidoc index 4ee3ad7e71..a33ad651f7 100644 --- a/documentation/articles/UsingBeanValidationToValidateInput.asciidoc +++ b/documentation/articles/UsingBeanValidationToValidateInput.asciidoc @@ -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 |