vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
604 stars 165 forks source link

Handle element initial text content from template mapped elements #8975

Open pleku opened 4 years ago

pleku commented 4 years ago

Given a template with contents

<a routerlink id="link">This is a router link</a>

It should be at least possible to change the text value from server side Java code, by expecting to replace the contents completely, including any children it might have. For parsing the initial text value, it is only supported when the element has no child elements, but just text content.

@Id("link") RouterLink link;
link.getText(); // returns "This is a router link"
link.setText("Another text value"); // would replace any children it has

If replacing children is not desired, it is recommended to workaround that by using another wrapper element for the text

<a routerlink id="link"><iron-icon icon="vaadin:vaadin-h"></iron-icon><span id="link-text">Link with icon</span></a>
@Id("link-text") Span linkText;

linkText.setText("At least this is possible to do");
pleku commented 3 years ago

Reopened to be reconsidered if-and-how we should make this happen as the current implementation is broken in #10106 reverted by #10831.