Class AbstractAction

java.lang.Object
com.vaadin.flow.component.trigger.AbstractAction
All Implemented Interfaces:
Action, Serializable
Direct Known Subclasses:
ClickAction, ClipboardCopyAction, JsAction, ServerCallbackAction, SetEnabledAction

public abstract class AbstractAction extends Object implements Action
Base class for Action implementations.

Subclasses identify themselves with a namespaced type id ("flow:clipboard-copy", "myapp:show-toast", …) which must match a factory registered against window.Vaadin.Flow.triggers on the client side. Subclasses override buildClientConfig(com.vaadin.flow.component.trigger.internal.ConfigContext) to ship configuration with the action; if the action has a server-observable effect that should stay in sync with what just ran in the browser, they also override applyServerSideEffect().

See Also:
  • Constructor Details

    • AbstractAction

      protected AbstractAction(String typeId)
      Creates a new action with the given namespaced type id.
      Parameters:
      typeId - type id matching a client factory, not null
  • Method Details

    • getTypeId

      public final String getTypeId()
      The namespaced type id of this action.
      Returns:
      the type id, never null
    • buildClientConfig

      public tools.jackson.databind.node.ObjectNode buildClientConfig(ConfigContext context)
      Produces the JSON configuration this action sends to the client. Default is an empty object; override to add type-specific options.

      Subclasses encode output references by calling ConfigContext.registerOutput(Output) and element references by calling ConfigContext.referenceElement(com.vaadin.flow.dom.Element). Public so the internal framework can read the config without reflection; subclasses just override.

      Parameters:
      context - the resolver for referenced elements and outputs, not null
      Returns:
      a Jackson ObjectNode, never null
    • applyServerSideEffect

      public void applyServerSideEffect()
      Mirrors the client-side effect on the server. Called on the UI thread, at the start of the same server cycle that processes the triggering DOM event, before any user-attached event listeners run, so that listener code observes the post-action state.

      Default is a no-op. Subclasses with a server-observable effect (e.g. SetEnabledAction) override this.