Class UploadHelper
java.lang.Object
com.vaadin.flow.component.Component
org.vaadin.addons.f0rce.uploadhelper.UploadHelper
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasSize,java.io.Serializable
@Tag("lit-uploadhelper")
@JsModule("./@f0rce/uploadhelper/lit-uploadhelper.js")
@CssImport("./@f0rce/uploadhelper/styles.css")
public class UploadHelper
extends com.vaadin.flow.component.Component
implements com.vaadin.flow.component.HasSize
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classUploadHelper.UHFileRejectEventstatic classUploadHelper.UHUploadErrorEventstatic classUploadHelper.UHUploadStartEventstatic classUploadHelper.UHUploadSuccessEvent -
Constructor Summary
Constructors Constructor Description UploadHelper(com.vaadin.flow.component.Component dropZone, java.lang.String shadowDomDropZone, UHReceiver receiver)UploadHelper(com.vaadin.flow.component.Component dropZone, UHReceiver receiver)UploadHelper(java.lang.String dropZone, java.lang.String shadowDomDropZone, UHReceiver receiver)UploadHelper(java.lang.String dropZone, UHReceiver receiver)UploadHelper(UHReceiver receiver) -
Method Summary
Modifier and Type Method Description com.vaadin.flow.shared.RegistrationaddAllFinishedListener(com.vaadin.flow.component.ComponentEventListener<UHAllFinishedEvent> listener)Add listener that is informed on the finished upload.com.vaadin.flow.shared.RegistrationaddFailedListener(com.vaadin.flow.component.ComponentEventListener<UHFailedEvent> listener)Add a succeeded listener that is informed on upload failure.com.vaadin.flow.shared.RegistrationaddFileRejectedListener(com.vaadin.flow.component.ComponentEventListener<UHFileRejectedEvent> listener)Adds a listener foruh-file-rejectevents fired when a file cannot be added due to some constrains:setMaxFileSize, setAcceptedFileTypescom.vaadin.flow.shared.RegistrationaddFinishedListener(com.vaadin.flow.component.ComponentEventListener<UHFinishedEvent> listener)Add a succeeded listener that is informed on upload finished.com.vaadin.flow.shared.RegistrationaddProgressListener(com.vaadin.flow.component.ComponentEventListener<UHProgressUpdateEvent> listener)Add a progress listener that is informed on upload progress.com.vaadin.flow.shared.RegistrationaddStartedListener(com.vaadin.flow.component.ComponentEventListener<UHStartedEvent> listener)Add a succeeded listener that is informed on upload start.com.vaadin.flow.shared.RegistrationaddSucceededListener(com.vaadin.flow.component.ComponentEventListener<UHSucceededEvent> listener)Add a succeeded listener that is informed on upload succeeded.intgetMaxFiles()intgetMaxFileSize()Get the maximum allowed file size in the client-side, in bytes.UHReceivergetReceiver()Return the current receiver.booleanisVisualFeedback()Returns if visual feedback is enabled.voidremoveDropZone()Removes the dropZone / disables uploading to it.voidsetDropZone(com.vaadin.flow.component.Component dropZone)Sets the dropZone (theComponentwhich Upload-Helper should be enabled on).voidsetDropZone(com.vaadin.flow.component.Component dropZone, java.lang.String shadowDomDropZone)Sets the dropZone in theComponent's ShadowDom.voidsetDropZone(java.lang.String dropZone)Sets the dropZone (the Element ID which Upload-Helper should be enabled on).voidsetDropZone(java.lang.String dropZone, java.lang.String shadowDomDropZone)Sets the dropZone in the ShadowDom of given Element ID.voidsetMaxFiles(int maxFiles)Limit of files to upload, by default it is 1.voidsetMaxFileSize(int maxFileSize)Specify the maximum file size in bytes allowed to upload.voidsetReceiver(UHReceiver receiver)Sets a receiver.voidsetVisualFeedback(boolean visualFeedback)If set the false, the background color and the opacity of the dropZone Element is not changed.Methods inherited from class com.vaadin.flow.component.Component
from, getChildren, getElement, getId, getParent, getTranslation, getTranslation, getUI, isAttached, isVisible, onEnabledStateChanged, setId, setVisibleMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
-
Constructor Details
-
UploadHelper
-
UploadHelper
-
UploadHelper
public UploadHelper(com.vaadin.flow.component.Component dropZone, java.lang.String shadowDomDropZone, UHReceiver receiver) -
UploadHelper
-
UploadHelper
public UploadHelper(java.lang.String dropZone, java.lang.String shadowDomDropZone, UHReceiver receiver)
-
-
Method Details
-
setReceiver
Sets a receiver.- Parameters:
receiver-UHReceiver
-
setDropZone
public void setDropZone(com.vaadin.flow.component.Component dropZone)Sets the dropZone (theComponentwhich Upload-Helper should be enabled on).- Parameters:
dropZone-Component
-
setDropZone
public void setDropZone(com.vaadin.flow.component.Component dropZone, java.lang.String shadowDomDropZone)Sets the dropZone in theComponent's ShadowDom.- Parameters:
dropZone-ComponentshadowDomDropZone-String
-
setDropZone
public void setDropZone(java.lang.String dropZone)Sets the dropZone (the Element ID which Upload-Helper should be enabled on).- Parameters:
dropZone-String
-
setDropZone
public void setDropZone(java.lang.String dropZone, java.lang.String shadowDomDropZone)Sets the dropZone in the ShadowDom of given Element ID.- Parameters:
dropZone-StringshadowDomDropZone-String
-
removeDropZone
public void removeDropZone()Removes the dropZone / disables uploading to it. -
getReceiver
Return the current receiver.- Returns:
- the StreamVariable.
-
setMaxFileSize
public void setMaxFileSize(int maxFileSize)Specify the maximum file size in bytes allowed to upload. Notice that it is a client-side constraint, which will be checked before sending the request.- Parameters:
maxFileSize- the maximum file size in bytes
-
getMaxFileSize
public int getMaxFileSize()Get the maximum allowed file size in the client-side, in bytes.- Returns:
- the maximum file size in bytes
-
setMaxFiles
public void setMaxFiles(int maxFiles)Limit of files to upload, by default it is 1. If the value is set to one, native file browser will prevent selecting multiple files.- Parameters:
maxFiles- int
-
getMaxFiles
public int getMaxFiles()- Returns:
- maxFiles int
-
addAllFinishedListener
public com.vaadin.flow.shared.Registration addAllFinishedListener(com.vaadin.flow.component.ComponentEventListener<UHAllFinishedEvent> listener)Add listener that is informed on the finished upload.- Parameters:
listener- all finished listener to add- Returns:
- a
Registrationfor removing the event listener
-
addProgressListener
public com.vaadin.flow.shared.Registration addProgressListener(com.vaadin.flow.component.ComponentEventListener<UHProgressUpdateEvent> listener)Add a progress listener that is informed on upload progress.- Parameters:
listener- progress listener to add- Returns:
- registration for removal of listener
-
addFailedListener
public com.vaadin.flow.shared.Registration addFailedListener(com.vaadin.flow.component.ComponentEventListener<UHFailedEvent> listener)Add a succeeded listener that is informed on upload failure.- Parameters:
listener- failed listener to add- Returns:
- registration for removal of listener
-
addFinishedListener
public com.vaadin.flow.shared.Registration addFinishedListener(com.vaadin.flow.component.ComponentEventListener<UHFinishedEvent> listener)Add a succeeded listener that is informed on upload finished.- Parameters:
listener- finished listener to add- Returns:
- registration for removal of listener
-
addStartedListener
public com.vaadin.flow.shared.Registration addStartedListener(com.vaadin.flow.component.ComponentEventListener<UHStartedEvent> listener)Add a succeeded listener that is informed on upload start.- Parameters:
listener- start listener to add- Returns:
- registration for removal of listener
-
addSucceededListener
public com.vaadin.flow.shared.Registration addSucceededListener(com.vaadin.flow.component.ComponentEventListener<UHSucceededEvent> listener)Add a succeeded listener that is informed on upload succeeded.- Parameters:
listener- succeeded listener to add- Returns:
- registration for removal of listener
-
addFileRejectedListener
public com.vaadin.flow.shared.Registration addFileRejectedListener(com.vaadin.flow.component.ComponentEventListener<UHFileRejectedEvent> listener)Adds a listener foruh-file-rejectevents fired when a file cannot be added due to some constrains:setMaxFileSize, setAcceptedFileTypes- Parameters:
listener- the listener- Returns:
- a
Registrationfor removing the event listener
-
setVisualFeedback
public void setVisualFeedback(boolean visualFeedback)If set the false, the background color and the opacity of the dropZone Element is not changed. Else CSS Classes are added to have some kind of visual feedback.- Parameters:
visualFeedback- boolean
-
isVisualFeedback
public boolean isVisualFeedback()Returns if visual feedback is enabled.- Returns:
- boolean
-