Package org.wicketstuff.html5.fileapi
Class FileFieldChangeBehavior
java.lang.Object
org.apache.wicket.behavior.Behavior
org.apache.wicket.behavior.AbstractAjaxBehavior
org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
org.apache.wicket.ajax.AjaxEventBehavior
org.wicketstuff.html5.fileapi.FileFieldChangeBehavior
- All Implemented Interfaces:
Serializable,IComponentAwareEventSink,IRequestListener,IComponentAwareHeaderContributor,IClusterable
- Direct Known Subclasses:
FileFieldSizeCheckBehavior
A Behavior that can be used on FileUploadField-s to receive ajax callback with
detailed information about the chosen files when an event occurs (default: "onchange"). When the
ajax call is triggered (for example user selects files for upload) the metadata about the file(s)
(name, size, type, last modify date) is sent with the ajax call to the server (so the content is
not). Subclasses of this class can respond to this event by implementing the
onEvent(AjaxRequestTarget, FileList) method.
Works with single or multiple enabled file inputs.
Note that this behaviour only works with browsers implementing the Html5 FileApi (Chrome 11, Firefox 4). It does not change or break browsers not implementing the api.
- Author:
- akiraly
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault maximum number of files that are processed from the ajax request: 100.protected static final ResourceReferenceFields inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
INDICATOR -
Constructor Summary
ConstructorsModifierConstructorDescriptionDefault constructor: the monitored event is "onchange" and maxNumOfFiles isDEFAULT_MAX_NUM_OF_FILES.FileFieldChangeBehavior(int maxNumOfFiles) Constructor.protectedFileFieldChangeBehavior(String event, int maxNumOfFiles) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the configured max.protected voidonEvent(AjaxRequestTarget target) protected abstract voidonEvent(AjaxRequestTarget target, FileList fileList) Called during the ajax callback.voidrenderHead(Component component, IHeaderResponse response) protected voidupdateAjaxAttributes(AjaxRequestAttributes attributes) Methods inherited from class org.apache.wicket.ajax.AjaxEventBehavior
getEvent, onEvent, respondMethods inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
findIndicatorId, getAttributes, getCallbackFunction, getCallbackFunctionBody, getCallbackScript, getCallbackScript, onBind, onMethodMismatch, onRequest, postprocessConfiguration, renderAjaxAttributes, renderAjaxAttributesMethods inherited from class org.apache.wicket.behavior.AbstractAjaxBehavior
afterRender, bind, getCallbackUrl, getComponent, onComponentRendered, onComponentTag, onComponentTag, onUnbind, unbindMethods inherited from class org.apache.wicket.behavior.Behavior
beforeRender, canCallListener, detach, getStatelessHint, isEnabled, isTemporary, onAttribute, onConfigure, onEvent, onException, onRemove, onTagMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.wicket.IRequestListener
rendersPage
-
Field Details
-
JAVASCRIPT_REF
-
DEFAULT_MAX_NUM_OF_FILES
public static final int DEFAULT_MAX_NUM_OF_FILESDefault maximum number of files that are processed from the ajax request: 100.- See Also:
-
-
Constructor Details
-
FileFieldChangeBehavior
public FileFieldChangeBehavior()Default constructor: the monitored event is "onchange" and maxNumOfFiles isDEFAULT_MAX_NUM_OF_FILES. -
FileFieldChangeBehavior
public FileFieldChangeBehavior(int maxNumOfFiles) Constructor. The monitored event is "onchange".- Parameters:
maxNumOfFiles- maximum number of files that are processed from the ajax request, non-negative
-
FileFieldChangeBehavior
Constructor.- Parameters:
event- event for which the ajax call is triggered, not-nullmaxNumOfFiles- maximum number of files that are processed from the ajax request, non-negative
-
-
Method Details
-
renderHead
- Specified by:
renderHeadin interfaceIComponentAwareHeaderContributor- Overrides:
renderHeadin classAjaxEventBehavior
-
onEvent
- Specified by:
onEventin classAjaxEventBehavior
-
onEvent
Called during the ajax callback.- Parameters:
target- wicket object representing the ajax response, not-nullfileList- list of files chosen in the upload field, not-null
-
updateAjaxAttributes
- Overrides:
updateAjaxAttributesin classAjaxEventBehavior
-
getMaxNumOfFiles
public int getMaxNumOfFiles()Returns the configured max.- Returns:
- maximum number of files that are processed from the ajax request, non-negative
-