Annotation Type DelegateToWidget


  • @Target({METHOD,FIELD})
    public @interface DelegateToWidget
    Signals that the property value from a state class should be forwarded to the Widget of the corresponding connector instance.

    When this annotation is present on a field or on a setter method, the framework will call the corresponding setter in the Connector's Widget instance with the current state property value whenever it has been changed. This is happens after firing ConnectorHierarchyChangeEvents but before firing any StateChangeEvent.

    Take for example a state class looking like this:

     public class MyComponentState extends AbstractComponentState {
         @DelegateToWidget
         public String myProperty;
     }
     
    Whenever myProperty is changed, the framework will call code like this:
     connector.getWidget().setMyProperty(connector.getState().myProperty);
     

    By default, the Widget method to call is derived from the property name, but value() in the annotation can be used to provide a custom method name, e.g. @DelegateToWidget("someSpecialName").

    Since:
    7.0.0
    Author:
    Vaadin Ltd
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      String value
      Defines the name of the Widget method to call when the annotated state property has changed.
    • Element Detail

      • value

        String value
        Defines the name of the Widget method to call when the annotated state property has changed. If no value is defined, the method name will be derived from the property name, so e.g. a field named myProperty will delegate to a method named setMyProperty.
        Returns:
        the name of the method to delegate to, or empty string to use the default name
        Default:
        ""