diff options
author | AMahdy AbdelAziz <amahdy@users.noreply.github.com> | 2017-11-29 13:36:26 +0200 |
---|---|---|
committer | Aleksi Hietanen <aleksi@vaadin.com> | 2017-11-29 13:36:26 +0200 |
commit | 0bdf98c89034d424f93222a47de2a7240f572116 (patch) | |
tree | f87b377e59863f9bedecf694e64098abc1ef0ba7 | |
parent | cd8a5dab5658e72a7326f51ffbc1f0ff3bc470f8 (diff) | |
download | vaadin-framework-0bdf98c89034d424f93222a47de2a7240f572116.tar.gz vaadin-framework-0bdf98c89034d424f93222a47de2a7240f572116.zip |
Update bean validation article to use FW8 APIs (#10387)
Suggested by [Jean-Christophe Gueriaud](https://vaadin.com/forum/#!/thread/16876180).
Closes #10386
-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 |