Package com.vaadin.flow.component.upload
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.HasComponents,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-alpha7")
@JsModule("@vaadin/upload/src/vaadin-upload-drop-zone.js")
public class UploadDropZone
extends com.vaadin.flow.component.Component
implements com.vaadin.flow.component.HasComponents, 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(manager);
dropZone.add(new Span("Drop files here"));
add(dropZone);
- Author:
- Vaadin Ltd.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new empty drop zone without a manager.UploadDropZone(UploadManager manager) Creates a new drop zone linked to the given manager. -
Method Summary
Modifier and TypeMethodDescriptiondefault UploadManagerGets the upload manager that this component is linked to.voidsetEnabled(boolean enabled) Sets whether this drop zone is enabled.default voidsetUploadManager(UploadManager manager) 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, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasComponents
add, add, add, addComponentAsFirst, addComponentAtIndex, bindChildren, remove, remove, removeAllMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabledMethods 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, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Field Details
-
ATTACH_LISTENER_REGISTRATION
- See Also:
-
CONNECTOR_ATTACH_LISTENER_REGISTRATION
- See Also:
-
-
Constructor Details
-
UploadDropZone
public UploadDropZone()Creates a new empty drop zone without a manager. The manager must be set later usingsetUploadManager(UploadManager). -
UploadDropZone
Creates a new drop zone linked to the given manager.- Parameters:
manager- the upload manager to link to, notnull- Throws:
NullPointerException- if manager isnull
-
-
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:
setEnabledin interfacecom.vaadin.flow.component.HasEnabled- Parameters:
enabled-trueto enable the drop zone,falseto disable- See Also:
-
getUploadManager
Gets the upload manager that this component is linked to.- Returns:
- the upload manager, or
nullif not linked
-
setUploadManager
Sets the upload manager that this component is linked to.- Parameters:
manager- the upload manager, ornullto unlink
-