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:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     

    Fields inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior

    INDICATOR
  • Constructor Summary

    Constructors
    Constructor
    Description
    Listen for 'dragover' and 'drop' events and prevent them, only 'drop' will initiate an Ajax request.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Gets maximum count of files
    org.apache.wicket.util.lang.Bytes
     
    org.apache.wicket.util.lang.Bytes
     
    protected void
    onError(org.apache.wicket.ajax.AjaxRequestTarget target, org.apache.commons.fileupload2.core.FileUploadException fux)
    Hook method called to handle any error during uploading of the file.
    protected void
    onEvent(org.apache.wicket.ajax.AjaxRequestTarget target)
     
    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.
    void
    renderHead(org.apache.wicket.Component component, org.apache.wicket.markup.head.IHeaderResponse response)
     
    void
    setFileCountMax(long fileCountMax)
    Sets maximum amount of files in upload request.
    void
    setFileMaxSize(org.apache.wicket.util.lang.Bytes fileMaxSize)
    Set an optional maximum size per file.
    void
    setMaxSize(org.apache.wicket.util.lang.Bytes maxSize)
    Set the maximum upload size.
    protected void
    updateAjaxAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes 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 Details

  • Constructor Details

    • AjaxFileDropBehavior

      Listen for 'dragover' and 'drop' events and prevent them, only 'drop' will initiate an Ajax request.
  • Method Details

    • renderHead

      public void renderHead(org.apache.wicket.Component component, org.apache.wicket.markup.head.IHeaderResponse response)
      Specified by:
      renderHead in interface org.apache.wicket.markup.html.IComponentAwareHeaderContributor
      Overrides:
      renderHead in class org.apache.wicket.ajax.AjaxEventBehavior
    • updateAjaxAttributes

      protected void updateAjaxAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes attributes)
      Overrides:
      updateAjaxAttributes in class org.apache.wicket.ajax.AjaxEventBehavior
    • onEvent

      protected void onEvent(org.apache.wicket.ajax.AjaxRequestTarget target)
      Specified by:
      onEvent in class org.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 handler
      files - uploaded files
    • onError

      protected void onError(org.apache.wicket.ajax.AjaxRequestTarget target, org.apache.commons.fileupload2.core.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 handler
      fux - the error that occurred