com.vaadin.flow.component.webcomponent.
Class WebComponent<C extends Component>
Type Parameters:
C
- type of the component
exported as web component
All Implemented Interfaces:
Acts as a proxy to the web component root onto which the exporter
Component
is added. Allows updating web component properties and
firing custom events on the client-side.
Since:
2.0
Author:
Vaadin Ltd.
See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionWebComponent
(WebComponentBinding binding, Element componentHost) Constructs a
WebComponent
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Fires a custom event on the client-side originating from the web component.
void
Fires a custom event on the client-side originating from the web component with custom event data.
void
fireEvent
(String eventName, elemental.json.JsonValue objectData, EventOptions options) Fires a custom event on the client-side originating from the web component with custom event data.
<P extends Serializable>
voidsetProperty
(PropertyConfiguration<C, P> propertyConfiguration, P value) Sets property value on the client-side to the given
value
.
-
Constructor Details
-
WebComponent
Constructs a
WebComponent
.WebComponentBinding
provides the instance of theComponent
exported as a web component.Binding
also defines the properties the web component has.Element
is the host element which contains the exportedcomponent
instance (provided by thebinding
).Parameters:
binding
- binds web component configuration tocomponent X
componentHost
- hostcomponent X
on the embedding pageSee Also:
-
-
Method Details
-
fireEvent
Fires a custom event on the client-side originating from the web component. This event does not bubble in the DOM hierarchy.
Parameters:
eventName
- name of the event, not nullSee Also:
-
fireEvent
Fires a custom event on the client-side originating from the web component with custom event data. This event does not bubble in the DOM hierarchy.
Parameters:
eventName
- name of the event, not nullobjectData
- data the event should carry. This data is placed as thedetail
property of the event, nullableSee Also:
-
fireEvent
Fires a custom event on the client-side originating from the web component with custom event data. Allows modifying the default event behavior with
EventOptions
.Parameters:
eventName
- name of the event, not nullobjectData
- data the event should carry. This data is placed as thedetail
property of the event, nullableoptions
- event options forbubbles
,cancelable
, andcomposed
flags, not nullThrows:
NullPointerException
- if eithereventName
oroptions
isnull
-
setProperty
public <P extends Serializable> void setProperty(PropertyConfiguration<C, P> propertyConfiguration, P value) Sets property value on the client-side to the given
value
. The requiredPropertyConfigurationImpl
is received fromWebComponentExporter
when a new property is added for the web component.Type Parameters:
P
- type of the property value being set. If the type does not match the original property type, throws an exceptionParameters:
propertyConfiguration
- identifies the property for which the value is being set, notnull
value
- new value for the property, can benull
Throws:
NullPointerException
- ifpropertyConfiguration
isnull
IllegalArgumentException
- ifPropertyConfiguration
is not a correct implementationIllegalArgumentException
- if the web component does not have a property identified bypropertyConfiguration
IllegalArgumentException
- the providedvalue
is not of the type expected by the property
-