Class WebComponentBinding<C extends Component>
java.lang.Object
com.vaadin.flow.server.webcomponent.WebComponentBinding<C>
- Type Parameters:
C- type of the exported component
- All Implemented Interfaces:
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:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbindProperty(PropertyConfigurationImpl<C, ? extends Serializable> propertyConfiguration, boolean overrideDefault) Adds a property tothisweb component binding based on thepropertyConfiguration.voidbindProperty(PropertyConfigurationImpl<C, ? extends Serializable> propertyConfiguration, boolean overrideDefault, tools.jackson.databind.JsonNode startingValue) Adds a property tothisweb component binding based on thepropertyConfiguration.Retrieves the boundComponentinstance.Class<? extends Serializable> getPropertyType(String propertyName) Retrieve the type of a property's value.booleanhasProperty(String propertyName) Does the component binding have a property identified by given name.voidCalls the bound change handlers defined viaPropertyConfiguration.onChange(SerializableBiConsumer)for each bound property with the current value of the property.voidupdateProperty(String propertyName, Serializable value) Updates a property bound to thecomponent.voidupdateProperty(String propertyName, tools.jackson.databind.node.BaseJsonNode jsonValue) Updates a property bound to thecomponent.
-
Constructor Details
-
WebComponentBinding
Constructs a newWebComponentBinding. The boundComponentis given viacomponentparameter. The web component properties are bound by callingbindProperty(PropertyConfigurationImpl, boolean, JsonNode);- Parameters:
component- component which exposespropertiesas web component. Notnull- Throws:
NullPointerException- ifcomponentisnull
-
-
Method Details
-
updateProperty
Updates a property bound to thecomponent. If the property has an attached listener, thevalueis also delivered to the listener. If thevalueisnull, the property is set to its default value (which could benull).- Parameters:
propertyName- name of the property, notnullvalue- new value to set for the property- Throws:
NullPointerException- ifpropertyNameisnullIllegalArgumentException- if no bound property can be found forpropertyName
-
updateProperty
Updates a property bound to thecomponent. Converts thejsonValueinto the correct type if able and then callsupdateProperty(String, java.io.Serializable).- Parameters:
propertyName- name of the property, notnulljsonValue- new value to set for the property- Throws:
NullPointerException- ifpropertyNameisnullIllegalArgumentException- if no bound property can be found forpropertyNameIllegalArgumentException- if thejsonValuecannot be converted to the type of the property identified bypropertyName.
-
getComponent
Retrieves the boundComponentinstance.- Returns:
componentinstance
-
getPropertyType
Retrieve the type of a property's value.- Parameters:
propertyName- name of the property- Returns:
- property type
-
hasProperty
Does the component binding have a property identified by given name.- Parameters:
propertyName- name of the property- Returns:
- has property
-
updatePropertiesToComponent
public void updatePropertiesToComponent()Calls the bound change handlers defined viaPropertyConfiguration.onChange(SerializableBiConsumer)for each bound property with the current value of the property. -
bindProperty
public void bindProperty(PropertyConfigurationImpl<C, ? extends Serializable> propertyConfiguration, boolean overrideDefault) Adds a property tothisweb component binding based on thepropertyConfiguration. If a property with an existing name is bound, the previous binding is removed. Starting value for the property is set tonull.- Parameters:
propertyConfiguration- property configuration, notnulloverrideDefault- set totrueif the property should be initialized with null instead of default value found inPropertyData- Throws:
NullPointerException- ifpropertyConfigurationisnull
-
bindProperty
public void bindProperty(PropertyConfigurationImpl<C, ? extends Serializable> propertyConfiguration, boolean overrideDefault, tools.jackson.databind.JsonNode startingValue) Adds a property tothisweb component binding based on thepropertyConfiguration. If a property with an existing name is bound, the previous binding is removed.- Parameters:
propertyConfiguration- property configuration, notnulloverrideDefault- set totrueif the property should be initialized withstartingValueinstead of default value found inPropertyDatastartingValue- starting value for the property. Can benull.overrideDefaultmust betruefor this value to have any effect- Throws:
NullPointerException- ifpropertyConfigurationisnull
-