Class DisableOnClickController<C extends Component & HasEnabled>

java.lang.Object
com.vaadin.flow.component.shared.internal.DisableOnClickController<C>
Type Parameters:
C - Type of the component that uses this controller.
All Implemented Interfaces:
Serializable

@JsModule("./disableOnClickFunctions.js") public class DisableOnClickController<C extends Component & HasEnabled> extends Object implements Serializable
An internal controller for handling disabling a component when it is clicked. Not intended to be used publicly.

When setDisableOnClick(boolean) is enabled, the component will be immediately disabled upon clicking, both on the client-side and server-side, to prevent multiple clicks or submissions while the server processes the event.

This controller requires that the component implements HasEnabled.

Since:
24.6
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new controller for the given component.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Gets whether the component is set to be disabled when clicked.
    void
    Forces the client-side component's disabled property to be updated before the response is sent to the client, so that it matches the component's effective enabled state, including whether any parent is disabled.
    void
    setDisableOnClick(boolean disableOnClick)
    Sets whether the component should be disabled when clicked.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DisableOnClickController

      public DisableOnClickController(C component)
      Creates a new controller for the given component.
      Parameters:
      component - the component to control, not null
  • Method Details

    • setDisableOnClick

      public void setDisableOnClick(boolean disableOnClick)
      Sets whether the component should be disabled when clicked.

      When set to true, the component will be immediately disabled on the client-side when clicked, preventing further clicks until re-enabled from the server-side.

      Parameters:
      disableOnClick - whether the component should be disabled when clicked
    • isDisableOnClick

      public boolean isDisableOnClick()
      Gets whether the component is set to be disabled when clicked.
      Returns:
      whether the component is set to be disabled on click
    • onSetEnabled

      public void onSetEnabled()
      Forces the client-side component's disabled property to be updated before the response is sent to the client, so that it matches the component's effective enabled state, including whether any parent is disabled.

      This method should be called from the component's HasEnabled.setEnabled(boolean) method, after the enabled state has been updated.

      Since:
      25.2.7