Selaa lähdekoodia

Update bean validation article to use FW8 APIs (#10387)

Suggested by [Jean-Christophe Gueriaud](https://vaadin.com/forum/#!/thread/16876180).

Closes #10386
tags/8.3.0.alpha1
AMahdy AbdelAziz 6 vuotta sitten
vanhempi
commit
0bdf98c890

+ 5
- 6
documentation/articles/UsingBeanValidationToValidateInput.asciidoc Näytä tiedosto

@@ -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

Loading…
Peruuta
Tallenna