Class AbstractTrigger
java.lang.Object
com.vaadin.flow.component.trigger.AbstractTrigger
- All Implemented Interfaces:
Trigger,Serializable
- Direct Known Subclasses:
ClickTrigger,JsTrigger,ShortcutTrigger
Base class for
Trigger implementations.
Subclasses identify themselves with a namespaced type id
("flow:click", "myapp:double-tap", …) which must match a
factory registered against window.Vaadin.Flow.triggers on the client
side. Subclasses override
buildClientConfig(com.vaadin.flow.component.trigger.internal.ConfigContext)
when they need to ship extra configuration with the trigger.
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractTrigger(String typeId, Component host) Creates a new trigger bound to the given host component's root element.protectedAbstractTrigger(String typeId, Element host) Creates a new trigger bound to the given host element. -
Method Summary
Modifier and TypeMethodDescriptiontools.jackson.databind.node.ObjectNodebuildClientConfig(ConfigContext context) Produces the JSON configuration this trigger sends to the client.final ElementgetHost()The host element this trigger fires on.final intInternal id for this trigger within its host'sTriggerSupport.final StringThe namespaced type id of this trigger.final voidremove()Removes this trigger and all bindings created from it.final TriggerWires the given actions to this trigger.final Triggertriggers(SerializableRunnable serverHandler) Wires a server-side callback to this trigger.
-
Constructor Details
-
AbstractTrigger
Creates a new trigger bound to the given host element.- Parameters:
typeId- namespaced type id matching a client factory, notnullhost- the element the trigger fires on, notnull
-
AbstractTrigger
Creates a new trigger bound to the given host component's root element.- Parameters:
typeId- namespaced type id matching a client factory, notnullhost- the component whose root element the trigger fires on, notnull
-
-
Method Details
-
getHost
The host element this trigger fires on.- Returns:
- the host element, never
null
-
getTypeId
The namespaced type id of this trigger.- Returns:
- the type id, never
null
-
getTriggerId
public final int getTriggerId()Internal id for this trigger within its host'sTriggerSupport.- Returns:
- the id
-
buildClientConfig
Produces the JSON configuration this trigger sends to the client. Default is an empty object; override to add type-specific options.The
contextlets subclasses encode element/output references by id when needed. Public so the internal framework can read the config without reflection; subclasses just override.- Parameters:
context- the resolver for referenced elements and outputs, notnull- Returns:
- a Jackson
ObjectNode, nevernull
-
triggers
Description copied from interface:TriggerWires the given actions to this trigger. They run in the order given, inside the original DOM event handler, the next time this trigger fires. -
triggers
Description copied from interface:TriggerWires a server-side callback to this trigger. The callback runs after the client-side dispatch of any other bound actions has finished. The callback fires on the UI thread.This is sugar for adding a
ServerCallbackActionthat wraps the given runnable. -
remove
public final void remove()Description copied from interface:TriggerRemoves this trigger and all bindings created from it. The corresponding client-side handlers are detached as part of the next synchronisation.
-