public class FileUpload extends Div implements IUploadAcceptingComponent, IControl<UploadItem>
In the browser the primary upload thingy is an input type='file' component. This gets used to allow the user to add a file. As soon as a file is selected an onchange event will ensure the posting of the file to the server using an AJAX/IFrame upload. This upload will be received by the Upload part which will attach the file to the control doing the upload. When the upload is complete the input type="file" thing gets replaced by a "file reference" containing the input filename and a delete button. If the input thingy allows for multiple files to be uploaded another input type="file" gets added above that.
| Constructor and Description |
|---|
FileUpload() |
FileUpload(int maxfiles,
String allowedExt)
Create an upload item that acceps a max #of files and a set of extensions.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
void |
createContent() |
String |
getAllowedExtensions()
Return the space separated list of allowed file extensions.
|
List<UploadItem> |
getFiles()
Return the current value: the list of files that have been uploaded and
their related data.
|
int |
getMaxFiles() |
int |
getMaxSize() |
IValueChanged<?> |
getOnValueChanged() |
UploadItem |
getValue()
Returns the current value of this input component.
|
UploadItem |
getValueSafe()
Like
IControl.getValue() this returns the value of the component, but this returns null
if the value was invalid. |
boolean |
handleUploadRequest(RequestContextImpl param,
ConversationContext conversation) |
boolean |
isDisabled()
Returns T if the control is currently in disabled.
|
boolean |
isFull()
Return T if the max.
|
boolean |
isMandatory()
T if at least 1 file needs to be uploaded.
|
boolean |
isReadOnly()
Returns T if the control is currently in readonly mode.
|
void |
removeAllUploads() |
void |
removeUploadItem(UploadItem ufi)
Removes specified upload item.
|
void |
setAllowedExtensions(String allowedExtensions)
Set the list of allowed file extensions.
|
void |
setDisabled(boolean disabled)
Set the input to disabled mode.
|
void |
setMandatory(boolean required)
Set to T if at least one file needs to have been uploaded.
|
void |
setMaxFiles(int maxFiles) |
void |
setMaxSize(int maxSize) |
void |
setOnValueChanged(IValueChanged<?> onValueChanged) |
void |
setReadOnly(boolean readOnly)
Sets the input to readonly-mode.
|
void |
setValue(UploadItem v)
Set a new value into this control.
|
afterCreateContent, componentHandleWebAction, fadeIn, fadeOut, getCustomUpdatesCallJS, getDragHandler, getDropBody, getDropHandler, getDropMode, getReturnPressed, setDragHandler, setDropBody, setDropHandler, setReturnPressed, slideDown, slideUp, tb, visitadd, add, add, addTable, addTableForLayout, addTableForLayout, appendTreeErrors, canContain, createFrame, delegateTo, disableAllChildControlsDeep, findChildIndex, forceRebuild, getChild, getChildCount, getChildren, getDeepChildren, getDelegate, getErrorFence, getTextContents, hasError, internalAdd, internalCheckNotDirty, internalClearDelta, internalClearDeltaFully, internalCreateFrame, internalGetNodeCount, internalGetOldChildren, internalOnBeforeRender, internalShelve, internalUnshelve, iterator, onRefresh, removeAllChildren, removeChild, removeChild, replaceChild, setErrorFence, setErrorFence, setText, setValue, undelegatedAdd, undelegatedGetChild$, acceptRequestParameter, addBinding, addCssClass, addGlobalMessage, addNotificationListener, alignToLeft, alignToLeft, alignToMiddle, alignToMiddle, alignTopToBottom, alignTopToBottom, alignToRight, alignToRight, alignToTop, alignToTop, appendAfterMe, appendBeforeMe, appendCreateJS, appendJavascript, appendJQuerySelector, appendJsCustomUpdatesContributor, appendShowOverflowTextAsTitleJs, appendStatement, beforeCreateContent, bind, bind, bindErrors, build, calcTestID, changed, changedJavascriptState, clearFocusRequested, clearGlobalMessage, clearGlobalMessage, clearGlobalMessage, clearMessage, clearValidationFailure, componentHandleWebDataRequest, createStatement, findComponentBundle, findParent, getActualID, getAllocationTracepoint, getBindingErrors, getBindingList, getBrowserWindowSize, getCalculatedTestID, getClicked, getClientBounds, getComponentBundle, getComponentDataURL, getComponentDataURL, getComponentInfo, getComponentJSONURL, getCreateJS, getCssClass, getErrorList, getErrorLocation, getFocusID, getMessage, getOnClickJS, getOnMouseDownJS, getOnSizeAndPositionChange, getPage, getParent, getParent, getParent, getParentOfTypes, getSharedContext, getSharedContextFactory, getSpecialAttribute, getSpecialAttributeList, getTag, getTestID, getTestRepeatId, getThemedResourceRURL, getTitle, getUserObject, handleDrop, hasCssClass, hasParent, internalGetOldParent, internalGetParent, internalHasChangedAttributes, internalNeedClickHandler, internalOnClicked, internalOnValueChanged, internalRenderJavascriptDelta, internalRenderJavascriptState, internalSetHasChangedAttributes, internalSetHasChangedAttributes, internalSetLogAllocations, internalSetTag, isAttached, isBuilt, isFocusable, isFocusRequested, isRendersOwnClose, isStretchHeight, lc, notify, notifyParentOrOpenerPage, onAddedToPage, onBeforeFullRender, onBeforeRender, onForceRebuild, onHeaderContributors, onRemoveFromPage, onShelve, onUnshelve, refresh, remove, removeBinding, removeCssClass, renderJavascriptDelta, renderJavascriptState, renderJavascriptState, replaceWith, setBrowserWindowSize, setCalculcatedId, setCalculcatedId, setClicked, setClientBounds, setComponentBundle, setCssClass, setErrorLocation, setFocus, setMessage, setOnClickJS, setOnMouseDownJS, setOnSizeAndPositionChange, setOverrideTitle, setSpecialAttribute, setStretchHeight, setTestID, setTestRepeatID, setTitle, setUserObject, toStringgetBackgroundAttachment, getBackgroundColor, getBackgroundImage, getBackgroundPosition, getBackgroundRepeat, getBorderBottomColor, getBorderBottomStyle, getBorderBottomWidth, getBorderLeftColor, getBorderLeftStyle, getBorderLeftWidth, getBorderRightColor, getBorderRightStyle, getBorderRightWidth, getBorderTopColor, getBorderTopStyle, getBorderTopWidth, getBottom, getCachedStyle, getClear, getColor, getDisplay, getFloat, getFontFamily, getFontSize, getFontSizeAdjust, getFontStyle, getFontVariant, getFontWeight, getHeight, getLeft, getLineHeight, getMarginBottom, getMarginLeft, getMarginRight, getMarginTop, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOverflow, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getPosition, getRight, getTextAlign, getTop, getTransform, getVerticalAlign, getVisibility, getWidth, getZIndex, internalSetDisplay, setBackgroundAttachment, setBackgroundColor, setBackgroundImage, setBackgroundPosition, setBackgroundRepeat, setBorder, setBorder, setBorderBottomColor, setBorderBottomStyle, setBorderBottomWidth, setBorderColor, setBorderLeftColor, setBorderLeftStyle, setBorderLeftWidth, setBorderRightColor, setBorderRightStyle, setBorderRightWidth, setBorderStyle, setBorderTopColor, setBorderTopStyle, setBorderTopWidth, setBorderWidth, setBottom, setBottom, setCachedStyle, setClear, setColor, setDisplay, setFloat, setFontFamily, setFontSize, setFontSizeAdjust, setFontStyle, setFontVariant, setFontWeight, setHeight, setLeft, setLeft, setLineHeight, setMargin, setMarginBottom, setMarginLeft, setMarginRight, setMarginTop, setMaxHeight, setMaxWidth, setMinHeight, setMinWidth, setOverflow, setPadding, setPaddingBottom, setPaddingLeft, setPaddingRight, setPaddingTop, setPosition, setRight, setRight, setTextAlign, setTop, setTop, setTransform, setVerticalAlign, setVisibility, setWidth, setZIndexclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetErrorLocation, hasError, setErrorLocationsetTestIDclearMessage, getMessage, setMessageforEach, spliteratorpublic FileUpload()
public FileUpload(int maxfiles,
String allowedExt)
maxfiles - allowedExt - public void createContent()
throws Exception
createContent in class NodeBaseException@Nonnull public List<UploadItem> getFiles()
UploadItem contains a reference to the
actual file UploadItem.getFile(); this file remains present only
while the page is still alive. If the page is destroyed all of it's uploaded
files will be deleted. So if you need to retain the file somehow after upload
it's contents needs to be copied to either another file that you control
or to a BLOB in a database.@Nullable public UploadItem getValue()
IControlValidationException. This means that this
call either delivers correct input (as defined by it's converter and validators), null
(when empty) or throws an exception. When a ValidationException occurs the framework
mostly ignores it - it does not produce a stacktrace or error in the client. Instead
the resulting error as posted by the error handling framework gets displayed on the
form when the request completes.
To get the value of a component while ignoring exceptions call IControl.getValueSafe().
getValue in interface IControl<UploadItem>public void setValue(@Nullable UploadItem v)
IControlsetValue in interface IControl<UploadItem>@Nullable public UploadItem getValueSafe()
IControlIControl.getValue() this returns the value of the component, but this returns null
if the value was invalid. For this method NULL either means the value was invalid OR
it's content was empty. To distinguish between the two call IControl.hasError() or use
IControl.getValue() instead of this call.getValueSafe in interface IControl<UploadItem>public boolean isFull()
public void removeUploadItem(UploadItem ufi)
ufi - public void removeAllUploads()
public void clear()
public String getAllowedExtensions()
public void setAllowedExtensions(String allowedExtensions)
allowedExtensions - public boolean isMandatory()
isMandatory in interface IControl<UploadItem>public void setMandatory(boolean required)
setMandatory in interface IControl<UploadItem>required - public int getMaxFiles()
public void setMaxFiles(int maxFiles)
public IValueChanged<?> getOnValueChanged()
getOnValueChanged in interface IHasChangeListenerpublic void setOnValueChanged(IValueChanged<?> onValueChanged)
setOnValueChanged in interface IHasChangeListenerpublic boolean isDisabled()
IControlisDisabled in interface IControl<UploadItem>public void setDisabled(boolean disabled)
IActionControlsetDisabled in interface IActionControlpublic int getMaxSize()
public void setMaxSize(int maxSize)
public boolean handleUploadRequest(@Nonnull RequestContextImpl param, @Nonnull ConversationContext conversation) throws Exception
handleUploadRequest in interface IUploadAcceptingComponentExceptionpublic boolean isReadOnly()
IControlisReadOnly in interface IControl<UploadItem>public void setReadOnly(boolean readOnly)
IControlsetReadOnly in interface IControl<UploadItem>Copyright © 2017 etc.to. All rights reserved.