Class UploadButton

All Implemented Interfaces:
AttachNotifier, BlurNotifier<Button>, ClickNotifier<Button>, DetachNotifier, Focusable<Button>, FocusNotifier<Button>, HasAriaLabel, HasElement, HasEnabled, HasSize, HasStyle, HasText, HasTheme, HasPrefix, HasSuffix, HasThemeVariant<ButtonVariant>, HasTooltip, Serializable

@Tag("vaadin-upload-button") @NpmPackage(value="@vaadin/upload", version="25.1.0-alpha7") @JsModule("@vaadin/upload/src/vaadin-upload-button.js") public class UploadButton extends Button
A button component for triggering file uploads. When clicked, it opens a file picker dialog. This component is designed to work with UploadManager.

Example usage:

 var manager = new UploadManager(uploadHandler);
 var button = new UploadButton(manager);
 button.add(new Span("Select Files"));
 add(button);
 
Author:
Vaadin Ltd.
See Also:
  • Field Details

  • Constructor Details

    • UploadButton

      public UploadButton()
      Creates a new upload button without a manager. The manager must be set later using setUploadManager(UploadManager).
    • UploadButton

      public UploadButton(UploadManager manager)
      Creates a new upload button linked to the given manager.
      Parameters:
      manager - the upload manager to link to, not null
      Throws:
      NullPointerException - if manager is null
  • Method Details

    • setEnabled

      public void setEnabled(boolean enabled)
      Sets whether this button is enabled. When disabled, the button cannot be used to select files.

      Note: Disabling this button only affects the UI and does not prevent a malicious client from initiating uploads. To securely prevent uploads, use UploadManager.setEnabled(boolean).

      Specified by:
      setEnabled in interface HasEnabled
      Overrides:
      setEnabled in class Button
      Parameters:
      enabled - true to enable the button, false to disable
      See Also:
    • getUploadManager

      default UploadManager getUploadManager()
      Gets the upload manager that this component is linked to.
      Returns:
      the upload manager, or null if not linked
    • setUploadManager

      default void setUploadManager(UploadManager manager)
      Sets the upload manager that this component is linked to.
      Parameters:
      manager - the upload manager, or null to unlink