Class ContextInput<T>

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

public class ContextInput<T> extends Action.Input<T>
Reads a value out of the trigger context — the object a trigger supplies to describe what it fired for. A SinkTrigger rendered into a template supplies {args}, the arguments the template called the action with, so new ContextInput<String>("args", "0") yields the first of them at fire time.

This is what lets one action serve every element a renderer draws: the value is not captured on the server per element, the template passes it when the action runs.

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

See Also:
  • Constructor Details

    • ContextInput

      public ContextInput(String contextProperty, String valueProperty)
      Creates an input reading context[contextProperty][valueProperty] at fire time.
      Parameters:
      contextProperty - the context member to read from (e.g. "args"), not null
      valueProperty - the property to read off that member, 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 and context as runtime arguments (declared by the snippet that builds it with @JsFunctionParameterNames); inputs that need neither simply omit the declaration and ignore the arguments 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