From a15341140f8f8a391cd4a23184ba89366d8d5b08 Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 31 Jul 2020 09:25:34 +0300 Subject: [PATCH] Extend javadocs for Text and clarify not-supported API (#8799) Fixes #4882 --- .../java/com/vaadin/flow/component/Text.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/flow-server/src/main/java/com/vaadin/flow/component/Text.java b/flow-server/src/main/java/com/vaadin/flow/component/Text.java index 58f6e5b5cf1..507889e25da 100644 --- a/flow-server/src/main/java/com/vaadin/flow/component/Text.java +++ b/flow-server/src/main/java/com/vaadin/flow/component/Text.java @@ -19,6 +19,15 @@ /** * A component which encapsulates the given text in a text node. + *

+ * Text node doesn't support setting any attribute or property so you may not + * use Element API (and {@link Text} doesn't provide any such contract) for + * setting attribute/property. It implies that you may not style this component + * as well. Any attempt to set attribute/property value throws an exception. The + * only available API for a {@link Text} component is set a text. + *

+ * If you need a text component which can be styled then check {@code Span} + * class (from {@code flow-html-components}) module. * * @author Vaadin Ltd * @since 1.0 @@ -67,6 +76,25 @@ protected void set(PropertyDescriptor descriptor, T value) { + "represent an HTML Element but a text Node on the client side."); } + /** + * The method is not supported for the {@link Text} class. + *

+ * Always throws an {@link UnsupportedOperationException}. + * + * @throws UnsupportedOperationException + */ + @Override + public void setId(String id) { + super.setId(id); + } + + /** + * The method is not supported for the {@link Text} class. + *

+ * Always throws an {@link UnsupportedOperationException}. + * + * @throws UnsupportedOperationException + */ @Override public void setVisible(boolean visible) { throw new UnsupportedOperationException("Cannot change "