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;
     }
     
     
    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.

    Since:

    1.0

    Author:

    Vaadin Ltd

    • Optional Element Summary

      Optional Elements
      Modifier and Type Optional Element and Description
      String value

      The id of the element to map to.

    • 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:

        ""