Class UploadDropZone

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

@Tag("vaadin-upload-drop-zone") @NpmPackage(value="@vaadin/upload", version="25.1.0-beta1") @JsModule("@vaadin/upload/src/vaadin-upload-drop-zone.js") public class UploadDropZone extends com.vaadin.flow.component.Component implements com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.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(new Span("Drop files here"), manager);
 add(dropZone);
 
Author:
Vaadin Ltd.
See Also:
  • Field Summary

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

    Constructors
    Constructor
    Description
    Creates a new empty drop zone without a manager.
    UploadDropZone(com.vaadin.flow.component.Component content, UploadManager manager)
    Creates a new drop zone with the given content, linked to the given manager.
    Creates a new drop zone linked to the given manager.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.vaadin.flow.component.Component
    Returns the content of the drop zone.
    Gets the upload manager that this component is linked to.
    void
    setContent(com.vaadin.flow.component.Component content)
    Sets the content of the drop zone.
    void
    setEnabled(boolean enabled)
    Sets whether this drop zone is enabled.
    default void
    Sets the upload manager that this component is linked to.

    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.DetachNotifier

    addDetachListener

    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.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
  • 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
    • UploadDropZone

      public UploadDropZone(com.vaadin.flow.component.Component content, UploadManager manager)
      Creates a new drop zone with the given content, linked to the given manager.
      Parameters:
      content - the content to set
      manager - the upload manager to link to, not null
      Throws:
      NullPointerException - if manager is null
  • Method Details

    • getContent

      public com.vaadin.flow.component.Component getContent()
      Returns the content of the drop zone. Returns null if the drop zone has no content.
      Returns:
      the content of the drop zone
    • setContent

      public void setContent(com.vaadin.flow.component.Component content)
      Sets the content of the drop zone. Set null to remove the current content.
      Parameters:
      content - the content to set
    • 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 com.vaadin.flow.component.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