Annotation Type Id


  • @Retention(RUNTIME)
    @Target(FIELD)
    @Documented
    @Deprecated
    public @interface Id
    Deprecated.
    Use com.vaadin.flow.component.template.Id instead. Polymer template support is deprecated - we recommend you to use LitTemplate instead. Read more details from the Vaadin blog.
    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;
     }
     
     
    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. Attribute values declared on the client side are reflected to the server side as property values or attribute values.

    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.

    Since:
    1.0
    Author:
    Vaadin Ltd
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      String value
      Deprecated.
      The id of the element to map to.
    • Element Detail

      • value

        String value
        Deprecated.
        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:
        ""