public abstract class FileFieldChangeBehavior
extends org.apache.wicket.ajax.AjaxEventBehavior
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.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_NUM_OF_FILES
Default maximum number of files that are processed from the ajax request: 100.
|
protected static org.apache.wicket.request.resource.ResourceReference |
JAVASCRIPT_REF |
Modifier | Constructor and Description |
---|---|
|
FileFieldChangeBehavior()
Default constructor: the monitored event is "onchange" and maxNumOfFiles is
DEFAULT_MAX_NUM_OF_FILES . |
|
FileFieldChangeBehavior(int maxNumOfFiles)
Constructor.
|
protected |
FileFieldChangeBehavior(String event,
int maxNumOfFiles)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
getMaxNumOfFiles()
Returns the configured max.
|
protected void |
onEvent(org.apache.wicket.ajax.AjaxRequestTarget target) |
protected abstract void |
onEvent(org.apache.wicket.ajax.AjaxRequestTarget target,
FileList fileList)
Called during the ajax callback.
|
void |
renderHead(org.apache.wicket.Component component,
org.apache.wicket.markup.head.IHeaderResponse response) |
protected void |
updateAjaxAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes attributes) |
getEvent, onCheckEvent, respond
findIndicatorId, getAttributes, getCallbackFunction, getCallbackFunctionBody, getCallbackScript, getCallbackScript, onBind, onRequest, postprocessConfiguration, renderAjaxAttributes, renderAjaxAttributes
afterRender, bind, getCallbackUrl, getComponent, onComponentRendered, onComponentTag, onComponentTag, onUnbind, unbind
protected static final org.apache.wicket.request.resource.ResourceReference JAVASCRIPT_REF
public static final int DEFAULT_MAX_NUM_OF_FILES
public FileFieldChangeBehavior()
DEFAULT_MAX_NUM_OF_FILES
.public FileFieldChangeBehavior(int maxNumOfFiles)
maxNumOfFiles
- maximum number of files that are processed from the ajax request, non-negativeprotected FileFieldChangeBehavior(String event, int maxNumOfFiles)
event
- event for which the ajax call is triggered, not-nullmaxNumOfFiles
- maximum number of files that are processed from the ajax request, non-negativepublic void renderHead(org.apache.wicket.Component component, org.apache.wicket.markup.head.IHeaderResponse response)
renderHead
in interface org.apache.wicket.markup.html.IComponentAwareHeaderContributor
renderHead
in class org.apache.wicket.ajax.AjaxEventBehavior
protected void onEvent(org.apache.wicket.ajax.AjaxRequestTarget target)
onEvent
in class org.apache.wicket.ajax.AjaxEventBehavior
protected abstract void onEvent(org.apache.wicket.ajax.AjaxRequestTarget target, FileList fileList)
target
- wicket object representing the ajax response, not-nullfileList
- list of files chosen in the upload field, not-nullprotected void updateAjaxAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes attributes)
updateAjaxAttributes
in class org.apache.wicket.ajax.AjaxEventBehavior
public int getMaxNumOfFiles()
Copyright © 2015. All rights reserved.