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
,IComponentAwareEventSink
,IRequestListener
,IComponentAwareHeaderContributor
,IClusterable
public class AjaxFileDropBehavior extends AjaxEventBehavior
Uploads files from a drop event.- Author:
- Andrew Kondratev, svenmeier
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
DRAG_OVER_CLASS_KEY
-
Fields inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
INDICATOR
-
-
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 long
getFileCountMax()
Gets maximum count of filesBytes
getFileMaxSize()
Bytes
getMaxSize()
protected void
onError(AjaxRequestTarget target, org.apache.commons.fileupload.FileUploadException fux)
Hook method called to handle any error during uploading of the file.protected void
onEvent(AjaxRequestTarget target)
Listener method for the ajax eventprotected void
onFileUpload(AjaxRequestTarget target, List<FileUpload> files)
Hook method called after a file was uploaded.void
renderHead(Component component, IHeaderResponse response)
Render to the web response whatever the component wants to contribute to the head section.void
setFileCountMax(long fileCountMax)
Sets maximum amount of files in upload request.void
setFileMaxSize(Bytes fileMaxSize)
Set an optional maximum size per file.void
setMaxSize(Bytes maxSize)
Set the maximum upload size.protected void
updateAjaxAttributes(AjaxRequestAttributes attributes)
Gives a chance to the specializations to modify the attributes.-
Methods inherited from class org.apache.wicket.ajax.AjaxEventBehavior
getEvent, onEvent, respond
-
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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.wicket.IRequestListener
rendersPage
-
-
-
-
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(Component component, IHeaderResponse response)
Description copied from class:Behavior
Render to the web response whatever the component wants to contribute to the head section.- Specified by:
renderHead
in interfaceIComponentAwareHeaderContributor
- Overrides:
renderHead
in classAjaxEventBehavior
- Parameters:
component
- component which is contributing to the response. This parameter is here to give the component as the context for component-awares implementing this interfaceresponse
- Response object- See Also:
Behavior.renderHead(Component, org.apache.wicket.markup.head.IHeaderResponse)
-
updateAjaxAttributes
protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
Description copied from class:AbstractDefaultAjaxBehavior
Gives a chance to the specializations to modify the attributes.- Overrides:
updateAjaxAttributes
in classAjaxEventBehavior
-
onEvent
protected void onEvent(AjaxRequestTarget target)
Description copied from class:AjaxEventBehavior
Listener method for the ajax event- Specified by:
onEvent
in classAjaxEventBehavior
- Parameters:
target
- the current request handler
-
getMaxSize
public Bytes getMaxSize()
-
setMaxSize
public void setMaxSize(Bytes maxSize)
Set the maximum upload size.- Parameters:
maxSize
- maximum size, must not be null
-
getFileMaxSize
public Bytes getFileMaxSize()
-
setFileMaxSize
public void setFileMaxSize(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(AjaxRequestTarget target, List<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(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
-
-