Errai 3.0.1-SNAPSHOT

org.jboss.errai.ui.shared.api.annotations
Annotation Type DataField


@Inherited
@Documented
@Target(value={FIELD,METHOD,PARAMETER})
@Retention(value=RUNTIME)
public @interface DataField

Indicates that the target Java reference (field, method parameter, or constructor parameter) in a Templated Composite component corresponds to an HTML element in the class's companion template.

This annotation can only be used in subclasses of Composite that have been annotated with Templated, or in super-classes of such Composite types.

The matching of Java references to HTML elements is performed as follows:

  1. A name for the Java reference is determined. If the @DataField annotation has a value() argument, it is used as the reference name. For fields, the default name is the field name. Method and constructor parameters have no default name, so they must always specify a value.
  2. If there is an element in the HTML template with attribute data-field=name, the Java reference will point to this element. If there is more than one such element, the Java reference will point to the first.
  3. Otherwise, if there is an element in the HTML template with attribute id=name, the Java reference will point to this element. If there is more than one such element, the Java reference will point to the first.
  4. Otherwise, if there is an element in the HTML template with a CSS style class name, the Java reference will point to this element. If there is more than one such element, the Java reference will point to the first. For elements with more than one CSS style, each style name is considered individually. For example:
      <div class="eat drink be-merry">
     
    matches Java references named eat, drink, or be-merry.
  5. If no matching element is found by this point, it is an error.

If more than one Java reference matches the same HTML element in the template, it is an error. For example, given a template containing the element <div class="eat drink be-merry">, the following Java code is in error:

Author:
Lincoln Baxter, III, Christian Sadilek , Jonathan Fuerth

Optional Element Summary
 String value
          Specify the name of the data-field in the corresponding HTML template, which the annotated element represents.
 

value

public abstract String value
Specify the name of the data-field in the corresponding HTML template, which the annotated element represents.

Default:
""

Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.