You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/flow/binding-data/components-binder-validation.adoc
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,15 +59,15 @@ binder.forField(titleField)
59
59
60
60
=== Custom Validation Error Messages
61
61
62
-
You can customize the way error messages are displayed by defining a [classname]`ValidationStatusHandler`. Or you can do so by configuring the [classname]`Label` for each binding.
62
+
You can customize the way error messages are displayed by defining a [classname]`ValidationStatusHandler`. Or you can do so by configuring a status label component for each binding.
63
63
64
-
The label is used to show the status of the field. It can be used for validation errors, as well as confirmation and helper messages.
64
+
The status label is used to show the status of the field. It can be used for validation errors, as well as confirmation and helper messages.
65
65
66
66
The example below shows how to configure validation messages for email and minimum-length validation:
67
67
68
68
[source,java]
69
69
----
70
-
Label emailStatus = new Label();
70
+
Span emailStatus = new Span();
71
71
emailStatus.getStyle().set("color", "Red");
72
72
binder.forField(emailField)
73
73
.withValidator(new EmailValidator(
@@ -77,7 +77,7 @@ binder.forField(emailField)
77
77
.withStatusLabel(emailStatus)
78
78
.bind(Person::getEmail, Person::setEmail);
79
79
80
-
Label nameStatus = new Label();
80
+
Span nameStatus = new Span();
81
81
82
82
binder.forField(nameField)
83
83
// Define the validator
@@ -94,9 +94,9 @@ binder.forField(nameField)
94
94
.bind(Person::getName, Person::setName);
95
95
----
96
96
97
-
The [methodname]`withStatusLabel(Label label)` method sets the given label to show an error message if the validation fails.
97
+
The [methodname]`withStatusLabel(HasText label)` method sets the given component to show an error message if the validation fails.
98
98
99
-
As an alternative to using labels, you can set a custom validation status handler, using the [methodname]`withValidationStatusHandler()` method. This allows you to customize how the binder displays error messages. It's also more flexible than using the status label approach.
99
+
As an alternative to using status labels, you can set a custom validation status handler, using the [methodname]`withValidationStatusHandler()` method. This allows you to customize how the binder displays error messages. It's also more flexible than using the status label approach.
0 commit comments