com.vaadin.flow.component.polymertemplate.
Annotation Type Id
-
@Retention(value=RUNTIME) @Target(value=FIELD) @Documented public @interface Id
Defines the id of an element to map to inside a
PolymerTemplate
.Use this annotation with an identifier of the element which you want to refer to as a value for a field inside your
PolymerTemplate
class.Here is a Java sample:
@Tag("details") public class Details extends PolymerTemplate<EditorModel>{ @Id("name") private Div nestedDiv; @Id("email") private Element nestedElement; }
<dom-module id="details"> <template> <div id='name'> <label>Text</label> </div> <input type="text" id='email'></div"> </template> ....
It's important to understand that the element's hierarchical structure for the element injected via
@Id
is not populated and not available on the server side (it's not known). It means thatnestedDiv
field value which is aDiv
component doesn't have any child on the server side. Also attribute values declared on the client side are not available on the server side.You still may use
Component
's orElement
's mutation methods for the injected element from the server side though. E.g. you may add a child or set attribute/property value. Such children will be available in the element's hierarchy in the same way as for a regular element.Since:
1.0
Author:
Vaadin Ltd
-
-
Element Detail
-
value
public abstract String value
The id of the element to map to. When empty, the name of the field is used instead.
Returns:
the id of the element to map to
Default:
""
-
-