]> source.dussan.org Git - vaadin-framework.git/commitdiff
Update datamodel-forms.asciidoc (#10350)
authorjcgueriaud <jeanchristophe.gueriaud@gmail.com>
Wed, 22 Nov 2017 11:58:08 +0000 (12:58 +0100)
committerTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>
Wed, 22 Nov 2017 11:58:08 +0000 (13:58 +0200)
This patch fixes the BinderValidationStatusHandler example in the documentation.

documentation/datamodel/datamodel-forms.asciidoc

index 2987e9ac1d2cfb0f30247f98dd1405d7370e0fb0..f307144a57cfcaa5d32e7f70beae2f1a62740cf6 100644 (file)
@@ -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);
 });
 ----