Class WebComponentBinding<C extends Component>

  • Type Parameters:
    C - type of the exported component
    All Implemented Interfaces:
    Serializable

    public final class WebComponentBinding<C extends Component>
    extends Object
    implements Serializable
    Represents a single instance of a exported web component instance embedded onto a host page. Contains a unique Component instance and property value hosts tied to the specific web component instance. Facilitates property updates from the client to the component.
    Since:
    2.0
    Author:
    Vaadin Ltd.
    See Also:
    to create , Serialized Form
    • Method Detail

      • updateProperty

        public void updateProperty​(String propertyName,
                                   Serializable value)
        Updates a property bound to the component. If the property has an attached listener, the value is also delivered to the listener. If the value is null, the property is set to its default value (which could be null).
        Parameters:
        propertyName - name of the property, not null
        value - new value to set for the property
        Throws:
        NullPointerException - if propertyName is null
        IllegalArgumentException - if no bound property can be found for propertyName
      • updateProperty

        public void updateProperty​(String propertyName,
                                   elemental.json.JsonValue jsonValue)
        Updates a property bound to the component. Converts the jsonValue into the correct type if able and then calls updateProperty(String, java.io.Serializable).
        Parameters:
        propertyName - name of the property, not null
        jsonValue - new value to set for the property
        Throws:
        NullPointerException - if propertyName is null
        IllegalArgumentException - if no bound property can be found for propertyName
        IllegalArgumentException - if the jsonValue cannot be converted to the type of the property identified by propertyName.
      • getComponent

        public C getComponent()
        Retrieves the bound Component instance.
        Returns:
        component instance
      • getPropertyType

        public Class<? extends Serializable> getPropertyType​(String propertyName)
        Retrieve the type of a property's value.
        Parameters:
        propertyName - name of the property
        Returns:
        property type
      • hasProperty

        public boolean hasProperty​(String propertyName)
        Does the component binding have a property identified by given name.
        Parameters:
        propertyName - name of the property
        Returns:
        has property
      • bindProperty

        public void bindProperty​(PropertyConfigurationImpl<C,​? extends Serializable> propertyConfiguration,
                                 boolean overrideDefault,
                                 elemental.json.JsonValue startingValue)
        Adds a property to this web component binding based on the propertyConfiguration. If a property with an existing name is bound, the previous binding is removed.
        Parameters:
        propertyConfiguration - property configuration, not null
        overrideDefault - set to true if the property should be initialized with startingValue instead of default value found in PropertyData
        startingValue - starting value for the property. Can be null. overrideDefault must be true for this value to have any effect
        Throws:
        NullPointerException - if propertyConfiguration is null