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 JSON-encoded into the JS at build time. 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 CopyTextToClipboardAction(new LiteralInput<>("hello"), () -> {
         }, 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.

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

    • appendExpression

      protected void appendExpression(com.vaadin.flow.component.trigger.internal.JsBuilder builder, StringBuilder out)
      Description copied from class: Action.Input
      Appends this input's JS expression to out. Element references must go through JsBuilder.reference(com.vaadin.flow.dom.Element).
      Specified by:
      appendExpression in class Action.Input<T>
      Parameters:
      builder - collects element parameter references, not null
      out - buffer to append into, not null