| Modifier and Type | Method and Description |
|---|---|
static <T extends ComponentEvent<?>> |
addListener(Component component,
Class<T> eventType,
ComponentEventListener<T> listener)
Adds a listener for an event of the given type to the
component. |
static <T extends ComponentEvent<?>> |
addListener(Component component,
Class<T> eventType,
ComponentEventListener<T> listener,
Consumer<DomListenerRegistration> domListenerConsumer)
Adds a listener for an event of the given type to the
component,
and customizes the corresponding DOM event listener with the given
consumer. |
static <T extends Component> |
componentFromElement(Element element,
Class<T> componentType,
boolean mapComponent)
Creates a new component instance using the given element, maps the
component to the element and optionally maps the element to the component
(if
mapComponent is true). |
static void |
findComponents(Element element,
Consumer<Component> componentConsumer)
|
static Optional<Component> |
findParentComponent(Element element)
Finds the first component by traversing upwards in the element hierarchy,
starting from the given element.
|
static <T extends Component> |
fireEvent(T component,
ComponentEvent<? extends T> componentEvent)
Dispatches the event to all listeners registered for the event type.
|
static <T> T |
getData(Component component,
Class<T> type)
Gets a data instance with the given type, or
null if there
is no such instance. |
static Object |
getData(Component component,
String key)
Gets a data instance with the given key, or
null if no data
has been set for that key. |
static ComponentMetaData.DependencyInfo |
getDependencies(VaadinService service,
Class<? extends Component> componentClass)
Gets the dependencies for the given class, defined using annotations (
HtmlImport, JavaScript, StyleSheet and
Uses). |
static Component |
getInnermostComponent(Composite<?> composite)
Returns the innermost component from a
Composite chain, i.e. |
static Component |
getInnermostComponent(Element element)
Gets the innermost mapped component for the element.
|
static Component |
getParentUsingComposite(Composite<?> composite,
Component component)
Gets the parent of the given component, which is inside the given
composite.
|
static Collection<ComponentMetaData.SynchronizedPropertyInfo> |
getSynchronizedProperties(Class<? extends Component> componentClass)
Gets the synchronized property infos of the properties that are defined
declaratively for the given class with their RPC update mode.
|
static Stream<String> |
getSynchronizedPropertyEvents(Class<? extends Component> componentClass)
Gets the name of the synchronized property event defined declaratively
for the given class.
|
static boolean |
isCompositeContent(Composite<?> composite,
Component component)
Checks if the given component is inside a
Composite chain, i.e. |
static void |
onComponentAttach(Component component,
boolean initialAttach)
Handles triggering the
onAttach
method and firing the AttachEvent for the given component when it
has been attached to a UI. |
static void |
onComponentDetach(Component component)
Handles triggering the
onDetach
method and firing the DetachEvent for the given component right
before it is detached from a UI. |
static <T> void |
setData(Component component,
Class<T> type,
T value)
Stores an instance of a specific type for the given component.
|
static void |
setData(Component component,
String key,
Object value)
Stores a arbitrary value for the given component.
|
public static void findComponents(Element element, Consumer<Component> componentConsumer)
Element subtree by
traversing the Element tree starting from the given element.element - the element to start scanning fromcomponentConsumer - a consumer which is called for each found componentpublic static Component getParentUsingComposite(Composite<?> composite, Component component)
This method is meant for internal use only.
composite - the composite containing the componentcomponent - the component to get the parent for, must be inside the
composite or a nested compositenullpublic static Component getInnermostComponent(Composite<?> composite)
Composite chain, i.e. the
first content which is not a Composite.composite - a composite in the chainpublic static boolean isCompositeContent(Composite<?> composite, Component component)
Composite chain, i.e.
it is a composite in the chain or the content of the innermost
Composite.composite - the first compositecomponent - the component to look fortrue if the component is inside the composite chain,
false otherwisepublic static Optional<Component> findParentComponent(Element element)
element - the element from which to begin the searchpublic static Component getInnermostComponent(Element element)
This returns Element.getComponent() if something else than a
Composite is mapped to the element. If a Composite is
mapped to the element, finds the innermost content of the
Composite chain.
element - the element which is mapped to a componentpublic static void onComponentAttach(Component component, boolean initialAttach)
onAttach
method and firing the AttachEvent for the given component when it
has been attached to a UI.component - the component attached to a UIinitialAttach - indicates if this is the first time the component (element)
has been attachedpublic static void onComponentDetach(Component component)
onDetach
method and firing the DetachEvent for the given component right
before it is detached from a UI.component - the component detached from a UIpublic static <T extends ComponentEvent<?>> Registration addListener(Component component, Class<T> eventType, ComponentEventListener<T> listener)
component.T - the component event typecomponent - the component to add the listenereventType - the component event type, not nulllistener - the listener to add, not nullpublic static <T extends ComponentEvent<?>> Registration addListener(Component component, Class<T> eventType, ComponentEventListener<T> listener, Consumer<DomListenerRegistration> domListenerConsumer)
component,
and customizes the corresponding DOM event listener with the given
consumer. This allows overriding eg. the debounce settings defined in the
DomEvent annotation.
Note that customizing the DOM event listener works only for event types
which are annotated with DomEvent. Use
addListener(Component, Class, ComponentEventListener) for other
listeners, or if you don't need to customize the DOM listener.
T - the event typecomponent - the component to add the listenereventType - the event type for which to call the listener, must be
annotated with DomEventlistener - the listener to call when the event occurs, not nulldomListenerConsumer - a consumer to customize the behavior of the DOM event
listener, not nullIllegalArgumentException - if the event type is not annotated with DomEventpublic static <T extends Component> void fireEvent(T component, ComponentEvent<? extends T> componentEvent)
T - the type of the componentcomponent - the component for which to fire eventscomponentEvent - the event to fireComponent.fireEvent(ComponentEvent)public static <T extends Component> T componentFromElement(Element element, Class<T> componentType, boolean mapComponent)
mapComponent is true).
This is a helper method for Element#as and Component#from.
T - the component typeelement - the elementcomponentType - the component typemapComponent - true to also map the element to the component,
false to only map the component to the elementComponent.from(Element, Class),
Element.as(Class)public static Collection<ComponentMetaData.SynchronizedPropertyInfo> getSynchronizedProperties(Class<? extends Component> componentClass)
componentClass - the component class to checkpublic static Stream<String> getSynchronizedPropertyEvents(Class<? extends Component> componentClass)
componentClass - the component class to checkpublic static ComponentMetaData.DependencyInfo getDependencies(VaadinService service, Class<? extends Component> componentClass)
HtmlImport, JavaScript, StyleSheet and
Uses).service - the service to use for resolving dependenciescomponentClass - the component class to checkpublic static void setData(Component component, String key, Object value)
component - the component for which to set the datakey - the key with which the instance can be retrieved, not
nullvalue - the data to set, or null to remove data
previously set with the same keysetData(Component, Class, Object),
getData(Component, String)public static <T> void setData(Component component, Class<T> type, T value)
T - the data instance typecomponent - the component for which to set the datatype - the type of the data to set, not nullvalue - the data instance to set, or null to remove data
previously set with the same typesetData(Component, String, Object),
getData(Component, Class)public static Object getData(Component component, String key)
null if no data
has been set for that key.component - the component from which to get the datakey - the data keynull if no instance has been
set using the given keysetData(Component, String, Object)public static <T> T getData(Component component, Class<T> type)
null if there
is no such instance.T - the data instance typecomponent - the component from which to get the datatype - the data typenull if no instance has been
set using the given typesetData(Component, Class, Object)Copyright © 2025. All rights reserved.