From 0bdf98c89034d424f93222a47de2a7240f572116 Mon Sep 17 00:00:00 2001 From: AMahdy AbdelAziz Date: Wed, 29 Nov 2017 13:36:26 +0200 Subject: Update bean validation article to use FW8 APIs (#10387) Suggested by [Jean-Christophe Gueriaud](https://vaadin.com/forum/#!/thread/16876180). Closes #10386 --- .../articles/UsingBeanValidationToValidateInput.asciidoc | 11 +++++------ 1 file 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 item = new BeanItem(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 binder = new BeanValidationBinder<>(Person.class); +binder.forField(firstName).bind("name"); +binder.setBean(person); .... Your `firstName` field is now automatically validated based on the -- cgit v1.2.3