Class HandlerInput<T>

java.lang.Object
com.vaadin.flow.component.trigger.internal.Action.Input<T>
com.vaadin.flow.component.trigger.internal.HandlerInput<T>
Type Parameters:
T - the runtime type of the value produced
All Implemented Interfaces:
Serializable

public final class HandlerInput<T> extends Action.Input<T>
Input that reads a property from a trigger handler's event argument (e.g. event.screenX for a DomEventTrigger).

Carries the trigger class the expression is valid for so that Trigger.triggers(Action...) refuses to render an input meant for one trigger family into the handler of an unrelated trigger (where the referenced variable would not be in scope). Class-based scoping lets a single input instance be exposed as a public static final field (see MouseEventTrigger.EventData) and reused across every instance of the owning class and its subclasses. Custom trigger families expose their event state the same way: declare a HandlerInput per property instead of subclassing Action.Input by hand.

For internal use only. May be renamed or removed in a future release.

Since:
25.2
See Also:
  • Constructor Details

    • HandlerInput

      public HandlerInput(String propertyName, Class<? extends Trigger> ownerClass)
      Creates an input that yields event[propertyName] at fire time, valid in the handler of any trigger that is an instance of ownerClass.
      Parameters:
      propertyName - the event property name, not null
      ownerClass - the trigger class the expression is valid for, 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