Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6abf20c

Browse files
Replace Label component usage with a valid alternative across the documentations. (#4719)
1 parent 7b10aa7 commit 6abf20c

File tree

9 files changed

+21
-21
lines changed

9 files changed

+21
-21
lines changed

articles/flow/binding-data/components-binder-validation.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ binder.forField(titleField)
5959

6060
=== Custom Validation Error Messages
6161

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.
6363

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.
6565

6666
The example below shows how to configure validation messages for email and minimum-length validation:
6767

6868
[source,java]
6969
----
70-
Label emailStatus = new Label();
70+
Span emailStatus = new Span();
7171
emailStatus.getStyle().set("color", "Red");
7272
binder.forField(emailField)
7373
.withValidator(new EmailValidator(
@@ -77,7 +77,7 @@ binder.forField(emailField)
7777
.withStatusLabel(emailStatus)
7878
.bind(Person::getEmail, Person::setEmail);
7979
80-
Label nameStatus = new Label();
80+
Span nameStatus = new Span();
8181
8282
binder.forField(nameField)
8383
// Define the validator
@@ -94,9 +94,9 @@ binder.forField(nameField)
9494
.bind(Person::getName, Person::setName);
9595
----
9696

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.
9898

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.
100100

101101

102102
=== Multiple Validators

articles/flow/binding-data/components-binder.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ To bind components that don't implement the [interfacename]`HasValue` interface
127127

128128
[source,java]
129129
----
130-
Label fullNameLabel = new Label();
130+
Span fullNameSpan = new Span();
131131
ReadOnlyHasValue<String> fullName =
132132
new ReadOnlyHasValue<>(
133-
text -> fullNameLabel.setText(text));
133+
text -> fullNameSpan.setText(text));
134134
binder.forField(fullName)
135135
.bind(Person::getFullName, null);
136136
----

articles/flow/create-ui/creating-components/composite.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ order: 5
1111

1212
This section demonstrates how to create a `Composite` component using existing components.
1313

14-
The example creates a `TextField` component by combining existing `Div`, `Label` and `Input` HTML components into this hierarchy:
14+
The example creates a `TextField` component by combining existing `Div`, `NativeLabel` and `Input` HTML components into this hierarchy:
1515

1616
* `Div`
17-
** `Label`
17+
** `NativeLabel`
1818
** `Input`
1919

2020
.Create the component based on a Composite
@@ -27,11 +27,11 @@ It's possible to create a new component by extending the `Div` HTML component, b
2727
----
2828
public class TextField extends Composite<Div> {
2929
30-
private Label label;
30+
private NativeLabel label;
3131
private Input input;
3232
3333
public TextField(String labelText, String value) {
34-
label = new Label();
34+
label = new NativeLabel();
3535
label.setText(labelText);
3636
input = new Input();
3737
input.setValue(value);
@@ -49,7 +49,7 @@ public class TextField extends Composite<Div> {
4949
== Adding an API
5050

5151
To make the component easier to use, you can add an API to get and set the value and label text.
52-
You do this by delegating to the `Input` and `Label` components.
52+
You do this by delegating to the `Input` and `NativeLabel` components.
5353

5454
*Example*: Adding an API to get and set the value and label.
5555

articles/flow/create-ui/element-api/shadow-root.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public class MyLabel extends Component {
3939
public MyLabel() {
4040
ShadowRoot shadowRoot = getElement()
4141
.attachShadow();
42-
Label textLabel = new Label("In the shadow");
43-
shadowRoot.appendChild(textLabel.getElement());
42+
Span textSpan = new Span("In the shadow");
43+
shadowRoot.appendChild(textSpan.getElement());
4444
}
4545
}
4646
----

articles/flow/create-ui/templates/components.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ The `@Id` annotation can also be used to inject an [classname]`Element` instance
7979
[source,java]
8080
----
8181
MainPage page = new MainPage();
82-
page.setContent(new Label("Hello!"));
82+
page.setContent(new Span("Hello!"));
8383
----
8484

8585

articles/flow/integrations/cdi/instantiated-beans.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class TestTemplate
6161
----
6262
@Dependent
6363
@Tag("dependent-label")
64-
public class DependentLabel extends Label {
64+
public class DependentLabel extends Span {
6565
@Inject
6666
private Greeter greeter;
6767

articles/flow/routing/exceptions.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public class FaultyBlogPostHandler extends Component
223223
public int setErrorParameter(BeforeEnterEvent event,
224224
ErrorParameter<IllegalArgumentException>
225225
parameter) {
226-
Label message = new Label(
226+
Span message = new Span(
227227
parameter.getCustomMessage());
228228
getElement().appendChild(message.getElement());
229229

articles/tools/mpr/configuration/limitations.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Legacy component events don't work unless you disable server-side modality of th
131131
----
132132
Dialog dialog = new Dialog();
133133
dialog.setHeaderTitle("Dialog");
134-
dialog.add(new Label("Hello"));
134+
dialog.add(new Span("Hello"));
135135
// Using legacy button
136136
LegacyWrapper wrapper = new LegacyWrapper(new Button("Close", e -> {
137137
dialog.close();

articles/tools/mpr/introduction/3-spring-boot.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ public class HelpView extends VerticalLayout implements View {
100100
HelpService service = context.getBean(HelpService.class);
101101
// every time when {@code context.getBean(HelpService.class)} called
102102
// the HelpService instance is the same until we're inside HelpView/HelpRoute
103-
Label label = new Label(service.getHelp());
104-
addComponent(label);
103+
Span helpSpan = new Span(service.getHelp());
104+
addComponent(helpSpan);
105105
}
106106
}
107107

0 commit comments

Comments
 (0)