Class UploadButton

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.button.Button
com.vaadin.flow.component.upload.UploadButton
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.component.button.Button>, com.vaadin.flow.component.ClickNotifier<com.vaadin.flow.component.button.Button>, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable<com.vaadin.flow.component.button.Button>, com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.button.Button>, com.vaadin.flow.component.HasAriaLabel, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasText, com.vaadin.flow.component.HasTheme, com.vaadin.flow.component.shared.HasPrefix, com.vaadin.flow.component.shared.HasSuffix, com.vaadin.flow.component.shared.HasThemeVariant<com.vaadin.flow.component.button.ButtonVariant>, com.vaadin.flow.component.shared.HasTooltip, Serializable

@Tag("vaadin-upload-button") @NpmPackage(value="@vaadin/upload", version="25.1.0-beta1") @JsModule("@vaadin/upload/src/vaadin-upload-button.js") public class UploadButton extends com.vaadin.flow.component.button.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("Select Files", manager);
 add(button);
 
Author:
Vaadin Ltd.
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier

    com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier

    com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component>

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasText

    com.vaadin.flow.component.HasText.WhiteSpace
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new upload button without a manager.
    Creates a new upload button linked to the given manager.
    Creates a new upload button with the given text, linked to the given manager.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the upload manager that this component is linked to.
    void
    setEnabled(boolean enabled)
    Sets whether this button is enabled.
    default void
    Sets the upload manager that this component is linked to.

    Methods inherited from class com.vaadin.flow.component.button.Button

    addBlurListener, addFocusListener, addFocusShortcut, bindText, click, clickInClient, getIcon, getText, isAutofocus, isDisableOnClick, isIconAfterText, remove, setAutofocus, setDisableOnClick, setIcon, setIconAfterText, setText

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.ClickNotifier

    addClickListener, addClickShortcut, addDoubleClickListener, addSingleClickListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.Focusable

    blur, focus, focus, getTabIndex, setTabIndex

    Methods inherited from interface com.vaadin.flow.component.HasAriaLabel

    getAriaLabel, getAriaLabelledBy, setAriaLabel, setAriaLabelledBy

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasEnabled

    bindEnabled, isEnabled

    Methods inherited from interface com.vaadin.flow.component.shared.HasPrefix

    getPrefixComponent, setPrefixComponent

    Methods inherited from interface com.vaadin.flow.component.HasSize

    bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName

    Methods inherited from interface com.vaadin.flow.component.shared.HasSuffix

    getSuffixComponent, setSuffixComponent

    Methods inherited from interface com.vaadin.flow.component.HasText

    getWhiteSpace, setWhiteSpace

    Methods inherited from interface com.vaadin.flow.component.HasTheme

    addThemeName, addThemeNames, bindThemeName, bindThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName

    Methods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant

    addThemeVariants, bindThemeVariant, removeThemeVariants, setThemeVariant, setThemeVariants, setThemeVariants

    Methods inherited from interface com.vaadin.flow.component.shared.HasTooltip

    getTooltip, setTooltipMarkdown, setTooltipText
  • 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
    • UploadButton

      public UploadButton(String text, UploadManager manager)
      Creates a new upload button with the given text, linked to the given manager.
      Parameters:
      text - the button text
      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 com.vaadin.flow.component.HasEnabled
      Overrides:
      setEnabled in class com.vaadin.flow.component.button.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