@Retention(value=RUNTIME) @Target(value=FIELD) @Documented public @interface Id
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;
}
This code may be used with the following template:
<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 that nestedDiv
field value which is a Div
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 or Element
'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.
public abstract String value
Copyright © 2020. All rights reserved.