Class LiteralInput<T>
java.lang.Object
com.vaadin.flow.component.trigger.internal.Action.Input<T>
com.vaadin.flow.component.trigger.internal.LiteralInput<T>
- Type Parameters:
T- the runtime type of the value
- All Implemented Interfaces:
Serializable
Input backed by a server-side literal that is captured into the rendered
JsFunction and Jackson-encoded into a JS value on the client. Lets
actions take Action.Input<? extends T> uniformly while still
accepting plain constants from callers ? e.g. copying a fixed string to the
clipboard:
new ClickTrigger(button).triggers(new WriteToClipboardAction(
new LiteralInput<>("hello"), null, copied -> {
}, err -> {
}));
The value is required to be non-null: null as a literal payload
almost never matches a sensible browser API call (e.g.
writeText(null) writes the string "null" to the clipboard).
Actions that need to emit a literal null should do so through their
own mechanism ? see SetPropertyAction's null-clearing convenience
constructor.
For internal use only. May be renamed or removed in a future release.
- Since:
- 25.2
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionBuilds theJsFunctionthat yields this input's value when called.
-
Constructor Details
-
LiteralInput
Creates a literal input wrapping the given value.- Parameters:
value- the value to encode, notnull
-
-
Method Details
-
toJs
Description copied from class:Action.InputBuilds theJsFunctionthat yields this input's value when called. The function may takeeventas a runtime argument (declared by the subclass viaJsFunction.withArguments(String...)); inputs that don't needeventsimply omit the declaration and ignore the argument the caller passes.Public so that
Actionimplementations in any package can consume inputs they receive as parameters, not only inputs they created themselves.- Specified by:
toJsin classAction.Input<T>- Parameters:
trigger- the surrounding trigger this render is for, notnull- Returns:
- the input's JS function, not
null
-