Class JsOutput<T>
java.lang.Object
com.vaadin.flow.component.trigger.AbstractOutput<T>
com.vaadin.flow.component.trigger.JsOutput<T>
- Type Parameters:
T- the runtime type of the produced value
- All Implemented Interfaces:
Output<T>,Serializable
Output backed by an arbitrary JavaScript expression — the escape hatch for
cases not covered by a built-in
AbstractOutput.
The expression runs at the moment the trigger fires and its return value
becomes the output. The expression executes in the global scope; use
document.querySelector(...) or other DOM globals to reach elements.
Output<String> hostName = new JsOutput<>(String.class,
"return window.location.hostname;");
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiontools.jackson.databind.node.ObjectNodebuildClientConfig(ConfigContext context) Produces the JSON configuration this output sends to the client.Methods inherited from class com.vaadin.flow.component.trigger.AbstractOutput
getTypeId, getValueType
-
Field Details
-
TYPE_ID
- See Also:
-
-
Constructor Details
-
JsOutput
Creates a JS-backed output.- Parameters:
valueType- the runtime type, notnullexpression- the JS source, notnull
-
-
Method Details
-
getExpression
- Returns:
- the JS expression
-
buildClientConfig
Description copied from class:AbstractOutputProduces the JSON configuration this output sends to the client. Default is an empty object; override to add type-specific options.Subclasses encode element references by calling
ConfigContext.referenceElement(com.vaadin.flow.dom.Element). Public so the internal framework can read the config without reflection; subclasses just override.- Overrides:
buildClientConfigin classAbstractOutput<T>- Parameters:
context- the resolver for referenced elements, notnull- Returns:
- a Jackson
ObjectNode, nevernull
-