to.etc.domui.component.upload
Class FileUpload

java.lang.Object
  extended by to.etc.domui.dom.css.CssBase
      extended by to.etc.domui.dom.html.NodeBase
          extended by to.etc.domui.dom.html.NodeContainer
              extended by to.etc.domui.dom.html.Div
                  extended by to.etc.domui.component.upload.FileUpload
All Implemented Interfaces:
java.lang.Iterable<NodeBase>, IModelBinding, INodeErrorDelegate, IDraggable, IDropTargetable

public class FileUpload
extends Div

Represents a file upload thingy which handles ajaxy uploads. The basic model is as follows:

Client side upload thingy

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.

Important info regarding IE use of iframe: http://p2p.wrox.com/topic.asp?whichpage=1&TOPIC_ID=62981𥟺

Author:
Frits Jalvingh Created on Oct 13, 2008

Constructor Summary
FileUpload()
           
FileUpload(int maxfiles, java.lang.String allowedExt)
          Create an upload item that acceps a max #of files and a set of extensions.
 
Method Summary
 void createContent()
           
 java.lang.String getAllowedExtensions()
          Return the space separated list of allowed file extensions.
 java.util.List<UploadItem> getFiles()
          Return the current value: the list of files that have been uploaded and their related data.
 int getMaxFiles()
           
 boolean isFull()
          Return T if the max.
 boolean isRequired()
          FIXME T if at least 1 file needs to be uploaded.
 void removeUploadItem(UploadItem ufi)
          Removes specified upload item.
 void setAllowedExtensions(java.lang.String allowedExtensions)
          Set the list of allowed file extensions.
 void setMaxFiles(int maxFiles)
           
 void setRequired(boolean required)
          Set to T if at least one file needs to have been uploaded.
 
Methods inherited from class to.etc.domui.dom.html.Div
afterCreateContent, componentHandleWebAction, fadeIn, fadeIn, fadeOut, getDragHandler, getDropBody, getDropHandler, getDropMode, getReturnPressed, setDragHandler, setDropBody, setDropHandler, setReturnPressed, slideDown, slideUp, tb, visit
 
Methods inherited from class to.etc.domui.dom.html.NodeContainer
add, add, add, addTable, canContain, delegateTo, findChildIndex, forceRebuild, getChild, getChildCount, getChildren, getDeepChild, getDeepChildren, getErrorFence, internalCheckNotDirty, internalClearDelta, internalClearDeltaFully, internalGetOldChildren, internalShelve, internalUnshelve, iterator, moveControlToModel, moveModelToControl, onRefresh, removeAllChildren, removeChild, removeChild, replaceChild, setControlsEnabled, setErrorFence, setErrorFence, setText, setValue
 
Methods inherited from class to.etc.domui.dom.html.NodeBase
$, acceptRequestParameter, addCssClass, addGlobalMessage, appendAfterMe, appendBeforeMe, appendCreateJS, appendJavascript, build, changed, clearFocusRequested, clearGlobalMessage, clearGlobalMessage, clearGlobalMessage, clearMessage, findComponentBundle, getActualID, getClicked, getComponentBundle, getCreateJS, getCssClass, getErrorDelegate, getErrorLocation, getMessage, getOnClickJS, getOnMouseDownJS, getPage, getParent, getParent, getParent, getSharedContext, getSpecialAttribute, getSpecialAttributeList, getTag, getTestID, getTitle, getUserObject, handleDrop, hasCssClass, hasError, internalGetOldParent, internalHasChangedAttributes, internalNeedClickHandler, internalOnClicked, internalSetHasChangedAttributes, internalSetHasChangedAttributes, internalSetTag, isBuilt, isFocusRequested, onAddedToPage, onBeforeFullRender, onForceRebuild, onHeaderContributors, onRemoveFromPage, onShelve, onUnshelve, refresh, remove, removeCssClass, renderJavascriptState, replaceWith, setClicked, setComponentBundle, setCssClass, setErrorDelegate, setErrorLocation, setFocus, setMessage, setOnClickJS, setOnMouseDownJS, setSpecialAttribute, setTestID, setTitle, setUserObject, stretchHeight, toString
 
Methods inherited from class to.etc.domui.dom.css.CssBase
getBackgroundAttachment, 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, 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, setPosition, setRight, setRight, setTextAlign, setTop, setTop, setTransform, setVerticalAlign, setVisibility, setWidth, setZIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileUpload

public FileUpload()

FileUpload

public FileUpload(int maxfiles,
                  java.lang.String allowedExt)
Create an upload item that acceps a max #of files and a set of extensions.

Parameters:
maxfiles -
allowedExt -
Method Detail

createContent

public void createContent()
                   throws java.lang.Exception
Overrides:
createContent in class NodeBase
Throws:
java.lang.Exception

getFiles

public java.util.List<UploadItem> getFiles()
Return the current value: the list of files that have been uploaded and their related data. The 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.

Returns:

isFull

public boolean isFull()
Return T if the max. #of files has been reached.

Returns:

removeUploadItem

public void removeUploadItem(UploadItem ufi)
Removes specified upload item.

Parameters:
ufi -

getAllowedExtensions

public java.lang.String getAllowedExtensions()
Return the space separated list of allowed file extensions.

Returns:

setAllowedExtensions

public void setAllowedExtensions(java.lang.String allowedExtensions)
Set the list of allowed file extensions.

Parameters:
allowedExtensions -

isRequired

public boolean isRequired()
FIXME T if at least 1 file needs to be uploaded.


setRequired

public void setRequired(boolean required)
Set to T if at least one file needs to have been uploaded.

Parameters:
required -

getMaxFiles

public int getMaxFiles()

setMaxFiles

public void setMaxFiles(int maxFiles)