Class SetEnabledAction

java.lang.Object
com.vaadin.flow.component.trigger.AbstractAction
com.vaadin.flow.component.trigger.SetEnabledAction
All Implemented Interfaces:
Action, Serializable

public class SetEnabledAction extends AbstractAction
Sets a target element's enabled state. Runs client-side by toggling the disabled attribute so the change is visible the instant the triggering DOM event handler returns — closing the latency window in which a user could otherwise click the element a second time before the server acknowledges the first click.

The server-side Component.setEnabled(boolean) (or Element.setEnabled(boolean)) mirror is applied in the next server cycle so application code observes the same enabled state.

See Also:
  • Field Details

  • Constructor Details

    • SetEnabledAction

      public SetEnabledAction(Element target, boolean enabled)
      Creates a set-enabled action.
      Parameters:
      target - the element to enable or disable, not null
      enabled - true to enable, false to disable
    • SetEnabledAction

      public SetEnabledAction(Component target, boolean enabled)
      Creates a set-enabled action targeting the component's root element.
      Parameters:
      target - the component to enable or disable, not null
      enabled - true to enable, false to disable
  • Method Details

    • getTarget

      public Element getTarget()
      Returns:
      the target element
    • isEnabled

      public boolean isEnabled()
      Returns:
      the value the action sets
    • buildClientConfig

      public tools.jackson.databind.node.ObjectNode buildClientConfig(ConfigContext context)
      Description copied from class: AbstractAction
      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.

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

      public void applyServerSideEffect()
      Description copied from class: AbstractAction
      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.

      Overrides:
      applyServerSideEffect in class AbstractAction