Class JsAction
java.lang.Object
com.vaadin.flow.component.trigger.AbstractAction
com.vaadin.flow.component.trigger.JsAction
- All Implemented Interfaces:
Action,Serializable
Action backed by an arbitrary JavaScript expression — the escape hatch for
cases not covered by a built-in
AbstractAction.
The expression runs every time the trigger fires. A single helper is in
scope: output(i) returns the resolved value of the i-th declared
output (in the order passed to this constructor).
Output<String> who = new PropertyOutput<>(field, "value", String.class);
new JsAction("alert('Hello ' + output(0));", who);
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiontools.jackson.databind.node.ObjectNodebuildClientConfig(ConfigContext context) Produces the JSON configuration this action sends to the client.Methods inherited from class com.vaadin.flow.component.trigger.AbstractAction
applyServerSideEffect, getTypeId
-
Field Details
-
TYPE_ID
- See Also:
-
-
Constructor Details
-
JsAction
Creates a JS-backed action.- Parameters:
expression- the JS source, notnulloutputs- outputs available to the expression viaoutput(i), in the order passed
-
-
Method Details
-
getExpression
- Returns:
- the JS expression
-
getOutputs
- Returns:
- the declared outputs in order
-
buildClientConfig
Description copied from class:AbstractActionProduces the JSON configuration this action sends to the client. Default is an empty object; override to add type-specific options.Subclasses encode output references by calling
ConfigContext.registerOutput(Output)and element references by callingConfigContext.referenceElement(com.vaadin.flow.dom.Element). Public so the internal framework can read the config without reflection; subclasses just override.- Overrides:
buildClientConfigin classAbstractAction- Parameters:
context- the resolver for referenced elements and outputs, notnull- Returns:
- a Jackson
ObjectNode, nevernull
-