Class AjaxFileDropBehavior
- java.lang.Object
-
- org.apache.wicket.behavior.Behavior
-
- org.apache.wicket.behavior.AbstractAjaxBehavior
-
- org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
-
- org.apache.wicket.ajax.AjaxEventBehavior
-
- org.apache.wicket.extensions.ajax.AjaxFileDropBehavior
-
- All Implemented Interfaces:
Serializable,org.apache.wicket.IComponentAwareEventSink,org.apache.wicket.IRequestListener,org.apache.wicket.markup.html.IComponentAwareHeaderContributor,org.apache.wicket.util.io.IClusterable
public class AjaxFileDropBehavior extends org.apache.wicket.ajax.AjaxEventBehavior
Uploads files from a drop event.- Author:
- Andrew Kondratev, svenmeier
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringDRAG_OVER_CLASS_KEY
-
Constructor Summary
Constructors Constructor Description AjaxFileDropBehavior()Listen for 'dragover' and 'drop' events and prevent them, only 'drop' will initiate an Ajax request.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetFileCountMax()Gets maximum count of filesorg.apache.wicket.util.lang.BytesgetFileMaxSize()org.apache.wicket.util.lang.BytesgetMaxSize()protected voidonError(org.apache.wicket.ajax.AjaxRequestTarget target, org.apache.commons.fileupload.FileUploadException fux)Hook method called to handle any error during uploading of the file.protected voidonEvent(org.apache.wicket.ajax.AjaxRequestTarget target)protected voidonFileUpload(org.apache.wicket.ajax.AjaxRequestTarget target, List<org.apache.wicket.markup.html.form.upload.FileUpload> files)Hook method called after a file was uploaded.voidrenderHead(org.apache.wicket.Component component, org.apache.wicket.markup.head.IHeaderResponse response)voidsetFileCountMax(long fileCountMax)Sets maximum amount of files in upload request.voidsetFileMaxSize(org.apache.wicket.util.lang.Bytes fileMaxSize)Set an optional maximum size per file.voidsetMaxSize(org.apache.wicket.util.lang.Bytes maxSize)Set the maximum upload size.protected voidupdateAjaxAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes attributes)-
Methods inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
findIndicatorId, getAttributes, getCallbackFunction, getCallbackFunctionBody, getCallbackScript, getCallbackScript, onBind, onMethodMismatch, onRequest, postprocessConfiguration, renderAjaxAttributes, renderAjaxAttributes
-
Methods inherited from class org.apache.wicket.behavior.AbstractAjaxBehavior
afterRender, bind, getCallbackUrl, getComponent, onComponentRendered, onComponentTag, onComponentTag, onUnbind, unbind
-
Methods inherited from class org.apache.wicket.behavior.Behavior
beforeRender, canCallListener, detach, getStatelessHint, isEnabled, isTemporary, onAttribute, onConfigure, onEvent, onException, onRemove, onTag
-
-
-
-
Field Detail
-
DRAG_OVER_CLASS_KEY
public static final String DRAG_OVER_CLASS_KEY
-
-
Constructor Detail
-
AjaxFileDropBehavior
public AjaxFileDropBehavior()
Listen for 'dragover' and 'drop' events and prevent them, only 'drop' will initiate an Ajax request.
-
-
Method Detail
-
renderHead
public void renderHead(org.apache.wicket.Component component, org.apache.wicket.markup.head.IHeaderResponse response)
- Specified by:
renderHeadin interfaceorg.apache.wicket.markup.html.IComponentAwareHeaderContributor- Overrides:
renderHeadin classorg.apache.wicket.ajax.AjaxEventBehavior
-
updateAjaxAttributes
protected void updateAjaxAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes attributes)
- Overrides:
updateAjaxAttributesin classorg.apache.wicket.ajax.AjaxEventBehavior
-
onEvent
protected void onEvent(org.apache.wicket.ajax.AjaxRequestTarget target)
- Specified by:
onEventin classorg.apache.wicket.ajax.AjaxEventBehavior
-
getMaxSize
public org.apache.wicket.util.lang.Bytes getMaxSize()
-
setMaxSize
public void setMaxSize(org.apache.wicket.util.lang.Bytes maxSize)
Set the maximum upload size.- Parameters:
maxSize- maximum size, must not be null
-
getFileMaxSize
public org.apache.wicket.util.lang.Bytes getFileMaxSize()
-
setFileMaxSize
public void setFileMaxSize(org.apache.wicket.util.lang.Bytes fileMaxSize)
Set an optional maximum size per file.- Parameters:
fileMaxSize- maximum size for each uploaded file
-
getFileCountMax
public long getFileCountMax()
Gets maximum count of files- Returns:
-
setFileCountMax
public void setFileCountMax(long fileCountMax)
Sets maximum amount of files in upload request.- Parameters:
fileCountMax-
-
onFileUpload
protected void onFileUpload(org.apache.wicket.ajax.AjaxRequestTarget target, List<org.apache.wicket.markup.html.form.upload.FileUpload> files)
Hook method called after a file was uploaded.Note:
onError(AjaxRequestTarget, FileUploadException)is called instead when uploading failed- Parameters:
target- the current request handlerfiles- uploaded files
-
onError
protected void onError(org.apache.wicket.ajax.AjaxRequestTarget target, org.apache.commons.fileupload.FileUploadException fux)
Hook method called to handle any error during uploading of the file.Default implementation re-throws the exception.
- Parameters:
target- the current request handlerfux- the error that occurred
-
-