diff options
author | jcgueriaud <jeanchristophe.gueriaud@gmail.com> | 2017-11-22 12:58:08 +0100 |
---|---|---|
committer | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2017-11-22 13:58:08 +0200 |
commit | 66f530355417e809b20cd452b449363fe6b0c060 (patch) | |
tree | 167fc26588dcb490496c3292131388aebfc15ab8 /documentation/datamodel/datamodel-forms.asciidoc | |
parent | 27c5730e2a6d552147e27a9669473ead555afc14 (diff) | |
download | vaadin-framework-66f530355417e809b20cd452b449363fe6b0c060.tar.gz vaadin-framework-66f530355417e809b20cd452b449363fe6b0c060.zip |
Update datamodel-forms.asciidoc (#10350)
This patch fixes the BinderValidationStatusHandler example in the documentation.
Diffstat (limited to 'documentation/datamodel/datamodel-forms.asciidoc')
-rw-r--r-- | documentation/datamodel/datamodel-forms.asciidoc | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/documentation/datamodel/datamodel-forms.asciidoc b/documentation/datamodel/datamodel-forms.asciidoc index 2987e9ac1d..f307144a57 100644 --- a/documentation/datamodel/datamodel-forms.asciidoc +++ b/documentation/datamodel/datamodel-forms.asciidoc @@ -506,27 +506,26 @@ We can also define our own status handler to provide a custom way of handling st // in order to display generated error messages separated by a <br> tag formStatusLabel.setContentMode(ContentMode.HTML); -BinderValidationStatusHandler defaultHandler = binder.getValidationStatusHandler(); +BinderValidationStatusHandler<Person> defaultHandler = binder.getValidationStatusHandler(); binder.setValidationStatusHandler(status -> { // create an error message on failed bean level validations - List<Result<?>> errors = status.getBeanValidationErrors(); + List<ValidationResult> errors = status.getBeanValidationErrors(); // collect all bean level error messages into a single string, // separating each message with a <br> tag - String errorMessage = errors.stream().map(Result::getMessage) - .map(o -> o.get()) - // sanitize the individual error strings to avoid code injection - // since we are displaying the resulting string as HTML - .map(errorString -> Jsoup.clean(errorString, Whitelist.simpleText())) - .collect(Collectors.joining("<br>")); + String errorMessage = errors.stream().map(ValidationResult::getErrorMessage) + // sanitize the individual error strings to avoid code injection + // since we are displaying the resulting string as HTML + .map(errorString -> Jsoup.clean(errorString, Whitelist.simpleText())) + .collect(Collectors.joining("<br>")); // finally, display all bean level validation errors in a single label formStatusLabel.setValue(errorMessage); formStatusLabel.setVisible(!errorMessage.isEmpty()); // Let the default handler show messages for each field - defaultHandler.accept(status); + defaultHandler.statusChange(status); }); ---- |