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

public final class LiteralInput<T> extends Action.Input<T>
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 Details

    • LiteralInput

      public LiteralInput(T value)
      Creates a literal input wrapping the given value.
      Parameters:
      value - the value to encode, not null
  • Method Details

    • toJs

      public JsFunction toJs(Trigger trigger)
      Description copied from class: Action.Input
      Builds the JsFunction that yields this input's value when called. The function may take event as a runtime argument (declared by the subclass via JsFunction.withArguments(String...)); inputs that don't need event simply omit the declaration and ignore the argument the caller passes.

      Public so that Action implementations in any package can consume inputs they receive as parameters, not only inputs they created themselves.

      Specified by:
      toJs in class Action.Input<T>
      Parameters:
      trigger - the surrounding trigger this render is for, not null
      Returns:
      the input's JS function, not null