Module org.apache.wicket.core
Class MultiFileUploadField
java.lang.Object
org.apache.wicket.Component
org.apache.wicket.MarkupContainer
org.apache.wicket.markup.html.WebMarkupContainer
org.apache.wicket.markup.html.form.LabeledWebMarkupContainer
org.apache.wicket.markup.html.form.FormComponent<T>
org.apache.wicket.markup.html.form.FormComponentPanel<Collection<FileUpload>>
org.apache.wicket.markup.html.form.upload.MultiFileUploadField
- All Implemented Interfaces:
Serializable
,Iterable<Component>
,IEventSink
,IEventSource
,IFeedbackContributor
,IConverterLocator
,IGenericComponent<Collection<FileUpload>,
,FormComponent<Collection<FileUpload>>> IMetadataContext<Serializable,
,Component> IQueueRegion
,IFormModelUpdateListener
,IFormVisitorParticipant
,ILabelProvider<String>
,IHeaderContributor
,IRequestableComponent
,IHierarchical<Component>
,IClusterable
Form component that allows the user to select multiple files to upload via a single <input
type="file"/> field.
Notice that this component clears its model at the end of the request, so the uploaded files MUST
be processed within the request they were uploaded.
Uses javascript implementation from
http://the-stickman.com/web-development/javascript/upload-multiple-files-with-a-single-file-element/
For customizing caption text see
RESOURCE_LIMITED
and RESOURCE_UNLIMITED
For an example of styling using CSS see the upload example in wicket-examples- Author:
- Igor Vaynberg (ivaynberg)
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final ResourceReference
static final String
static final String
Resource key used to retrieve caption message for when a limit on the number of uploads is specified.static final String
Resource key used to retrieve caption message for when no limit on the number of uploads is specified.static final int
Represents an unlimited max count of uploadsFields inherited from class org.apache.wicket.markup.html.form.FormComponent
FLAG_CONVERT_EMPTY_INPUT_STRING_TO_NULL, VALUE_SEPARATOR
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_INITIALIZED, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING, RFLAG_CONTAINER_HAS_REMOVALS
-
Constructor Summary
ConstructorDescriptionConstructorMultiFileUploadField
(String id, int max) ConstructorMultiFileUploadField
(String id, IModel<? extends Collection<FileUpload>> model) ConstructorMultiFileUploadField
(String id, IModel<? extends Collection<FileUpload>> model, int max) ConstructorMultiFileUploadField
(String id, IModel<? extends Collection<FileUpload>> model, int max, boolean useMultipleAttr) Constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected Collection<FileUpload>
convertValue
(String[] value) Subclasses should overwrite this if the conversion is not done through the type field and theIConverter
.protected boolean
The FileUploadField will close any input streams you have opened in its FileUpload by default.String[]
Gets the request parameters for this component as strings.boolean
protected void
Called on all visible components before any component is rendered.protected void
Processes the component tag.protected void
onDetach()
Sets the temporary converted input value to null.void
renderHead
(IHeaderResponse response) Render to the web response whatever the component wants to contribute to the head section.void
SeeFormComponent.updateCollectionModel(FormComponent)
for details on how the model is updated.Methods inherited from class org.apache.wicket.markup.html.form.FormComponentPanel
checkRequired, clearInput, newMarkupSourcingStrategy
Methods inherited from class org.apache.wicket.markup.html.form.FormComponent
add, add, convertInput, error, getConvertedInput, getDefaultLabel, getDefaultLabel, getForm, getInput, getInputName, getModelValue, getParameterValues, getRawInput, getType, getValidatorKeyPrefix, getValidators, getValue, hasRawInput, inputAsInt, inputAsInt, inputAsIntArray, inputChanged, internalOnModelChanged, invalid, isInputNullable, isRequired, isValid, newValidatable, newValidationError, onDisabled, onInvalid, onValid, processChildren, processInput, remove, reportRequiredError, setConvertedInput, setLabel, setModelValue, setRequired, setType, shouldTrimInput, trim, updateAutoLabels, updateAutoLabels, updateCollectionModel, valid, validate, validateRequired, validateValidators, visitComponentsPostOrder, visitFormComponentsPostOrder
Methods inherited from class org.apache.wicket.markup.html.form.LabeledWebMarkupContainer
getLabel
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSession
Methods inherited from class org.apache.wicket.MarkupContainer
add, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, getRegionMarkup, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onComponentTagBody, onInitialize, onRender, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, stream, streamChildren, toString, toString, visitChildren, visitChildren
Methods inherited from class org.apache.wicket.Component
add, addStateChange, beforeRender, canCallListener, canCallListenerAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, createConverter, debug, detach, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviorById, getBehaviorId, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessages, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkup, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdFromMarkup, getMarkupIdImpl, getMarkupSourcingStrategy, getMarkupTag, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getRequestFlag, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isInitialized, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, onAfterRender, onConfigure, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderPart, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlForListener, urlForListener, visitParents, visitParents, warn, wrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.wicket.IGenericComponent
getDefaultModel, getDefaultModelObject, getModel, getModelObject, setDefaultModel, setDefaultModelObject, setModel, setModelObject
Methods inherited from interface org.apache.wicket.IQueueRegion
dequeue, getRegionMarkup, newDequeueContext
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
UNLIMITED
Represents an unlimited max count of uploads- See Also:
-
RESOURCE_LIMITED
Resource key used to retrieve caption message for when a limit on the number of uploads is specified. The limit is represented via ${max} variable. Example: org.apache.wicket.mfu.caption.limited=Files (maximum ${max}):- See Also:
-
RESOURCE_UNLIMITED
Resource key used to retrieve caption message for when no limit on the number of uploads is specified. Example: org.apache.wicket.mfu.caption.unlimited=Files:- See Also:
-
MAGIC_SEPARATOR
- See Also:
-
JS
-
-
Constructor Details
-
MultiFileUploadField
Constructor- Parameters:
id
-
-
MultiFileUploadField
Constructor- Parameters:
id
-max
- max number of files a user can upload
-
MultiFileUploadField
Constructor- Parameters:
id
-model
-
-
MultiFileUploadField
Constructor- Parameters:
id
-model
-max
- max number of files a user can upload
-
MultiFileUploadField
public MultiFileUploadField(String id, IModel<? extends Collection<FileUpload>> model, int max, boolean useMultipleAttr) Constructor- Parameters:
id
-model
-max
- max number of files a user can uploaduseMultipleAttr
- true in order to use the new HTML5 "multiple" <input> attribute. It will allow the users to select multiple files at once for multiple times if the browser supports it, otherwise it will work just as before - one file multiple times.
-
-
Method Details
-
onComponentTag
Description copied from class:FormComponent
Processes the component tag.- Overrides:
onComponentTag
in classFormComponentPanel<Collection<FileUpload>>
- Parameters:
tag
- Tag to modify- See Also:
-
onBeforeRender
Description copied from class:Component
Called on all visible components before any component is rendered.NOTE: If you override this, you *must* call super.onBeforeRender() within your implementation. Because this method is responsible for cascading
Changes to the component tree can be made only before calling super.onBeforeRender().Component.onBeforeRender()
call to its children it is strongly recommended that super call is made at the end of the override.- Overrides:
onBeforeRender
in classFormComponent<Collection<FileUpload>>
- See Also:
-
isMultiPart
- Overrides:
isMultiPart
in classFormComponent<Collection<FileUpload>>
- Returns:
- True if this component encodes data in a multipart form submit
-
renderHead
Description copied from class:Component
Render to the web response whatever the component wants to contribute to the head section.- Specified by:
renderHead
in interfaceIHeaderContributor
- Overrides:
renderHead
in classComponent
- Parameters:
response
- Response object
-
getInputAsArray
Description copied from class:FormComponent
Gets the request parameters for this component as strings.- Overrides:
getInputAsArray
in classFormComponent<Collection<FileUpload>>
- Returns:
- The values in the request for this component
- See Also:
-
convertValue
Description copied from class:FormComponent
Subclasses should overwrite this if the conversion is not done through the type field and theIConverter
. WARNING: this method may be removed in future versions. If conversion fails then a ConversionException should be thrown- Overrides:
convertValue
in classFormComponent<Collection<FileUpload>>
- Parameters:
value
- The value can be the getInput() or through a cookie- Returns:
- The converted value. default returns just the given value
- Throws:
ConversionException
- If input can't be converted
-
updateModel
SeeFormComponent.updateCollectionModel(FormComponent)
for details on how the model is updated.- Specified by:
updateModel
in interfaceIFormModelUpdateListener
- Overrides:
updateModel
in classFormComponent<Collection<FileUpload>>
-
onDetach
Description copied from class:FormComponent
Sets the temporary converted input value to null.- Overrides:
onDetach
in classFormComponent<Collection<FileUpload>>
- See Also:
-
forceCloseStreamsOnDetach
The FileUploadField will close any input streams you have opened in its FileUpload by default. If you wish to manage the stream yourself (e.g. you want to use it in another thread) then you can override this method to prevent this behavior.- Returns:
true
if stream should be closed at the end of request
-