Class UploadDropZone

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.upload.UploadDropZone
All Implemented Interfaces:
AttachNotifier, DetachNotifier, HasComponents, HasElement, HasEnabled, HasSize, HasStyle, Serializable

@Tag("vaadin-upload-drop-zone") @NpmPackage(value="@vaadin/upload", version="25.1.0-alpha7") @JsModule("@vaadin/upload/src/vaadin-upload-drop-zone.js") public class UploadDropZone extends Component implements HasComponents, HasSize
A drop zone component for file uploads. When files are dropped on this component, they are added to the linked UploadManager.

The component has minimal styling by default. When files are dragged over it, the dragover attribute is set on the element, which can be used for styling.

Example usage with UploadManager:

 var manager = new UploadManager(uploadHandler);
 var dropZone = new UploadDropZone(manager);
 dropZone.add(new Span("Drop files here"));
 add(dropZone);
 
Author:
Vaadin Ltd.
See Also:
  • Field Details

  • Constructor Details

    • UploadDropZone

      public UploadDropZone()
      Creates a new empty drop zone without a manager. The manager must be set later using setUploadManager(UploadManager).
    • UploadDropZone

      public UploadDropZone(UploadManager manager)
      Creates a new drop zone 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 drop zone is enabled. When disabled, the drop zone will not accept dropped files.

      Note: Disabling this drop zone 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
      Parameters:
      enabled - true to enable the drop zone, 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