Project Wonder 5.0

er.ajax
Class AjaxFlexibleFileUpload

java.lang.Object
  extended by com.webobjects.appserver.WOElement
      extended by com.webobjects.appserver.WOComponent
          extended by er.ajax.AjaxFileUpload
              extended by er.ajax.AjaxFlexibleFileUpload
All Implemented Interfaces:
WOActionResults, NSKeyValueCoding, NSKeyValueCoding.ErrorHandling, NSKeyValueCodingAdditions, NSValidation, Serializable, Cloneable

public class AjaxFlexibleFileUpload
extends AjaxFileUpload

AjaxFlexibleFileUpload is an enhanced file upload component that uses a call to a hidden iFrame to handle a file upload. It is based on the code in AjaxFileUpload but extends it by using Andrew Valums' ajaxupload.js (from http://valums.com/ajax-upload/). This dynamically creates the iFrame at the end of the current page content freeing this component to be used in or out of a form. The component is fully styleable (including the upload button) and supports upload progress and canceling.

See Also:
Serialized Form
Author:
dleber, mschrag
Bindings
cancelLabel the label for for the cancel button (defaults to "Cancel")
           
startingText the text to display when the progress is starting (defaults "Upload Starting...");
           
selectFileLabel the label for the select file button (defaults to "Select File...")
           
clearLabel the label for the button used to clear a selected file or uploaded file (defaults to "Clear")
           
uploadLabel the label for the Upload button (defaults to "Upload")
           
startedFunction the javascript function to execute when the progress is started
           
canceledFunction the javascript function to execute when the upload is canceled
           
succeededFunction the javascript function to execute when the upload succeeds
           
clearedFunction the javascript function to execute when the clear button is clicked
           
failedFunction the javascript function to execute when the upload fails
           
finishedFunction the javascript function to execute when the upload finishes (succeeded, failed, or canceled)
           
finishedAction the action to fire when the upload finishes (cancel, failed, or succeeded)
           
canceledAction the action to fire when the upload is canceled
           
succeededAction the action to fire when the upload succeeded
           
clearedAction the action to fire when the clear button is clicked
           
failedAction the action to fire when the upload fails
           
data the NSData that will be bound with the contents of the upload
           
inputStream will be bound to an input stream on the contents of the upload
           
outputStream the output stream to write the contents of the upload to
           
streamToFilePath the path to write the upload to, can be a directory
           
finalFilePath the final file path of the upload (when streamToFilePath is set or keepTempFile = true)
           
filePath the name of the uploaded file
           
allowCancel if true, the cancel link is visible
           
refreshTime the number of milliseconds to wait between refreshes (defaults to 2000)
           
keepTempFile if true, don't delete the temp file that AjaxFileUpload creates
           
uploadFunctionName the upload button will instead be a function with the given name
           
autoSubmit should the upload start immediately after a file is selected (defaults to true)
           
injectDefaultCSS inject the default stylesheet from the Ajax framework (defaults to true);
           
selectFileButtonClass class for the select file button (defaults to "Button ObjButton SelectFileObjButton");
           
uploadButtonClass class for the select file button (defaults to "Button ObjButton UploadFileObjButton")
           
cancelButtonClass class for the select file button (defaults to "Button ObjButton CancelUploadObjButton")
           
clearButtonClass class for the select file button (defaults to "Button ObjButton ClearUploadObjButton")
           
clearUploadProgressOnSuccess if true, displays the select file button instead of the uploaded file name on completion of a successful upload
           
mimeType set from the content-type of the upload header if available
           

Nested Class Summary
static interface AjaxFlexibleFileUpload.Keys
           
static class AjaxFlexibleFileUpload.UploadState
           
 
Nested classes/interfaces inherited from class com.webobjects.appserver.WOComponent
WOComponent._EventLoggingEnabler, WOComponent.Event
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
NSKeyValueCodingAdditions.DefaultImplementation, NSKeyValueCodingAdditions.Utility
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCoding
NSKeyValueCoding._BooleanFieldBinding, NSKeyValueCoding._BooleanMethodBinding, NSKeyValueCoding._FieldBinding, NSKeyValueCoding._ForwardingBinding, NSKeyValueCoding._KeyBinding, NSKeyValueCoding._KeyBindingCreation, NSKeyValueCoding._MethodBinding, NSKeyValueCoding._NumberFieldBinding, NSKeyValueCoding._NumberMethodBinding, NSKeyValueCoding._ReflectionKeyBindingCreation, NSKeyValueCoding.ErrorHandling, NSKeyValueCoding.MapImplementation, NSKeyValueCoding.Null<T>, NSKeyValueCoding.UnknownKeyException, NSKeyValueCoding.ValueAccessor
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSValidation
NSValidation._MethodBinding, NSValidation._ValidationBinding, NSValidation.DefaultImplementation, NSValidation.Utility, NSValidation.ValidationException
 
Field Summary
protected  Logger log
           
 AjaxFlexibleFileUpload.UploadState state
           
 boolean testFlag
           
 
Fields inherited from class er.ajax.AjaxFileUpload
_progress, _triggerUploadStart, _uploadStarted
 
Fields inherited from class com.webobjects.appserver.WOComponent
_Extension, _IsEventLoggingEnabled, _keyAssociations
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding.ErrorHandling
_CLASS
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
_CLASS, _KeyPathSeparatorChar, KeyPathSeparator
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding
NullValue
 
Fields inherited from interface com.webobjects.foundation.NSValidation
_CLASS
 
Constructor Summary
AjaxFlexibleFileUpload(WOContext context)
           
 
Method Summary
protected  NSArray<String> _ajaxUploadData()
          Builds the array of required additional AjaxUpload data items (wosid, id).
protected  NSArray<String> _ajaxUploadLabels()
          Builds an array of localized label strings
protected  NSArray<String> _ajaxUploadOptions()
          Builds the array of AjaxUpload options
protected  NSArray<String> _options()
          Builds an array of AFU options
 String ajaxProxyName()
          Unique identifier for the ajax proxy object for this upload component
 String ajaxUploadData()
          Returns a comma separated string of AjaxUpload data items.
 String ajaxUploadLabels()
          Returns a comma separated string of the localized label strings.
 String ajaxUploadOptions()
          Returns a comma separated string of AjaxUpload options.
 String ajaxUploadScript()
          Generates the script to initialize a new AjaxUpload JS object
 Boolean allowCancel()
           
 void appendToResponse(WOResponse response, WOContext context)
           
 Boolean autoSubmit()
          Boolean which determines whether the upload should occur automatically after a file is selected.
 String cancelButtonClass()
          CSS Class for the cancel upload button
 String cancelButtonId()
          Element id for the cancel button
 String cancelLabel()
          Label for the cancel button
 void cancelUpload()
          Action called by the cancel upload button
 String cancelUploadFunction()
          JS function bound to the cancel button
 String cancelUrl()
          Returns a closeHTTPSession DA action URL passed to the iframe to cancel the client-side upload
 String clearButtonClass()
          CSS Class for the clear upload button
 WOActionResults clearFileResults()
          Action called by the clear button, resets the uploader for a new file selection
 String clearLabel()
          Label for the clear button
 String clearUploadButtonId()
          Element id for the clear button
 String clearUploadFunction()
          JS function bound to the clear button
 void clearUploadProgress()
          Helper to reset the uploader and unregister the AjaxProgress object
 Boolean clearUploadProgressOnSuccess()
           
 String fileNameId()
          Unique identifier for the fileName container
 String fileObjectId()
          Element id for the file object wrapper div
 String iframeId()
          Unique identifier for the iframe generated by the AjaxUploader.js
 String innerUpdateContainerId()
          Unique identifier for the inner update container
 String manualSubmitUploadFunction()
          JS function bound to the manual upload button
 String onChangeFunction()
          JS Function called when the AjaxUpload registers a change
 String onSubmitFunction()
          JS Function called when the AjaxUploader submits
 String options()
          Return a comma separated string of the AFU options
 String outerUpdateContainerId()
          Unique identifier for the outer update container
 Integer progressAmount()
          Calculate the current progress amount ( 0-100 )
 String progressBarValueId()
          Element id for the progress bar value inner div
 String progressWrapperId()
          Element id for the progress bar wrapper div
 String refreshTime()
          Returns the value for the binding 'refreshTime' The binding takes milliseconds between refreshes, this returns seconds
 String selectFileButtonClass()
          CSS Class for the select file button
 String selectFileButtonId()
          Element id for the select file button
 String selectFileButtonWrapperId()
          Element id for the select file button wrapper div
 String selectFileLabel()
          Label for the select file button
 String submitUploadButtonId()
          Element id for the manual upload submit button
 String uploadButtonClass()
          CSS Class for the upload file button
 String uploadButtonId()
          Unique identifier for the select files button
 WOActionResults uploadCanceled()
          Hook for add-in action called when an upload is canceled
 WOActionResults uploadFailed()
          Hook for add-in action called when an upload fails
 String uploadLabel()
          Label for the upload button
 String uploadName()
          Unique identifier for the upload name
 AjaxUploadProgress uploadProgress()
          Returns the AjaxUploadProgress for this uploader
 NSDictionary<String,?> uploadState()
          Generate a dictionary containing the current state of the upload.
 WOActionResults uploadSucceeded()
          Hook for add-in action called when an upload succeeds.
 
Methods inherited from class er.ajax.AjaxFileUpload
bytesReadSize, cancelingText, cancelText, id, isUploadStarted, progressBarAfterDone, progressBarBeforeStart, progressBarID, requestHandlerKey, setRequestHandlerKey, setUploadProgress, srcUrl, startingText, startUpload, startUploadFunctionCall, startUploadName, streamLengthSize, synchronizesVariablesWithBindings, triggerStartUpload, uploadFinished, uploadFormID, uploadFrameName, uploadUrl
 
Methods inherited from class com.webobjects.appserver.WOComponent
__valueForBinding, _associationWithName, _awakeInContext, _childTemplate, _cleanUpStatelessComponent, _componentDefinition, _componentUnroll, _isPage, _setContext, _setIsPage, _setParent, _setSubcomponent, _sleepInContext, _subcomponentForElementWithID, _templateNameForClass, _unroll, application, awake, baseURL, bindingKeys, canAccessFieldsDirectly, canGetValueForBinding, canSetValueForBinding, clone, context, debugString, descriptionForResponse, ensureAwakeInContext, frameworkName, generateResponse, handleQueryWithUnboundKey, handleTakeValueForUnboundKey, hasBinding, hasSession, invokeAction, isCachingEnabled, isEventLoggingEnabled, isStateless, logString, name, pageWithName, parent, path, pathURL, performParentAction, pullValuesFromParent, pushValuesToParent, reset, session, set_componentUnroll, set_unroll, setCachingEnabled, setValueForBinding, setVariableValueForName, sleep, takeValueForKey, takeValueForKeyPath, takeValuesFromRequest, template, templateWithHTMLString, templateWithHTMLString, templateWithHTMLString, templateWithName, toString, unableToSetNullForKey, validateTakeValueForKeyPath, validateValueForKey, validationFailedWithException, valueForBinding, valueForBooleanBinding, valueForIntegerBinding, valueForKey, valueForKeyPath, valueForNSArrayBindings, valueForNSDictionaryBindings, valueForNumberBinding, valueForStringBinding, variableValueForName, variableWithName
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected final Logger log

testFlag

public boolean testFlag

state

public AjaxFlexibleFileUpload.UploadState state
Constructor Detail

AjaxFlexibleFileUpload

public AjaxFlexibleFileUpload(WOContext context)
Method Detail

appendToResponse

public void appendToResponse(WOResponse response,
                             WOContext context)
Overrides:
appendToResponse in class AjaxFileUpload

ajaxUploadScript

public String ajaxUploadScript()
Generates the script to initialize a new AjaxUpload JS object

Returns:
script to initialize a new AjaxUpload JS object

_ajaxUploadData

protected NSArray<String> _ajaxUploadData()
Builds the array of required additional AjaxUpload data items (wosid, id).

Returns:
array of required additional AjaxUpload data items (wosid, id).

ajaxUploadData

public String ajaxUploadData()
Returns a comma separated string of AjaxUpload data items.

Returns:
comma separated string of AjaxUpload data items.

_ajaxUploadOptions

protected NSArray<String> _ajaxUploadOptions()
Builds the array of AjaxUpload options

Returns:
array of AjaxUpload options

ajaxUploadOptions

public String ajaxUploadOptions()
Returns a comma separated string of AjaxUpload options.

Returns:
comma separated string of AjaxUpload options.

_ajaxUploadLabels

protected NSArray<String> _ajaxUploadLabels()
Builds an array of localized label strings

Returns:
array of label/text strings

ajaxUploadLabels

public String ajaxUploadLabels()
Returns a comma separated string of the localized label strings.

Returns:
comma separated string of labels/text strings

_options

protected NSArray<String> _options()
Builds an array of AFU options

Returns:
array of AFU options

options

public String options()
Return a comma separated string of the AFU options

Returns:
comma separated string of options

onChangeFunction

public String onChangeFunction()
JS Function called when the AjaxUpload registers a change

Returns:
string JS Function called when the AjaxUpload registers a change

onSubmitFunction

public String onSubmitFunction()
JS Function called when the AjaxUploader submits

Returns:
string JS Function called when the AjaxUploader submits

uploadState

public NSDictionary<String,?> uploadState()
Generate a dictionary containing the current state of the upload.

Returns:
a dictionary containing the current state of the upload.

cancelUploadFunction

public String cancelUploadFunction()
JS function bound to the cancel button

Returns:
JS function bound to the cancel button

manualSubmitUploadFunction

public String manualSubmitUploadFunction()
JS function bound to the manual upload button

Returns:
JS function bound to the manul upload button

clearUploadFunction

public String clearUploadFunction()
JS function bound to the clear button

Returns:
JS function bound ot the clear button

cancelButtonId

public String cancelButtonId()
Element id for the cancel button

Returns:
id for the cancel button

clearUploadButtonId

public String clearUploadButtonId()
Element id for the clear button

Returns:
id for the clear button

submitUploadButtonId

public String submitUploadButtonId()
Element id for the manual upload submit button

Returns:
id for the upload button

selectFileButtonId

public String selectFileButtonId()
Element id for the select file button

Returns:
id for the select file button

selectFileButtonWrapperId

public String selectFileButtonWrapperId()
Element id for the select file button wrapper div

Returns:
id for the select file button wrapper div

fileObjectId

public String fileObjectId()
Element id for the file object wrapper div

Returns:
id for the file object wrapper div

progressWrapperId

public String progressWrapperId()
Element id for the progress bar wrapper div

Returns:
id for the progress bar wrapper div

progressBarValueId

public String progressBarValueId()
Element id for the progress bar value inner div

Returns:
id for the progress bar value inner div

ajaxProxyName

public String ajaxProxyName()
Unique identifier for the ajax proxy object for this upload component

Returns:
identifier for the ajax proxy object for this upload component

innerUpdateContainerId

public String innerUpdateContainerId()
Unique identifier for the inner update container

Returns:
identifier for the inner update container

outerUpdateContainerId

public String outerUpdateContainerId()
Unique identifier for the outer update container

Returns:
identifier for the outer update container

uploadButtonId

public String uploadButtonId()
Unique identifier for the select files button

Returns:
identifier for the select files button

iframeId

public String iframeId()
Unique identifier for the iframe generated by the AjaxUploader.js

Returns:
identifier for the iframe generated by the AjaxUploader.js

fileNameId

public String fileNameId()
Unique identifier for the fileName container

Returns:
identifier for the fileName container

uploadName

public String uploadName()
Unique identifier for the upload name

Returns:
identifier for the upload name

cancelUrl

public String cancelUrl()
Returns a closeHTTPSession DA action URL passed to the iframe to cancel the client-side upload

Returns:
url sent to the iframe to cancel

cancelUpload

public void cancelUpload()
Action called by the cancel upload button


clearFileResults

public WOActionResults clearFileResults()
Action called by the clear button, resets the uploader for a new file selection

Returns:
results of action

uploadCanceled

public WOActionResults uploadCanceled()
Hook for add-in action called when an upload is canceled

Overrides:
uploadCanceled in class AjaxFileUpload
Returns:
results of action

uploadFailed

public WOActionResults uploadFailed()
Hook for add-in action called when an upload fails

Overrides:
uploadFailed in class AjaxFileUpload
Returns:
results of action

uploadSucceeded

public WOActionResults uploadSucceeded()
Hook for add-in action called when an upload succeeds.

Overrides:
uploadSucceeded in class AjaxFileUpload

clearUploadProgress

public void clearUploadProgress()
Helper to reset the uploader and unregister the AjaxProgress object


uploadProgress

public AjaxUploadProgress uploadProgress()
Returns the AjaxUploadProgress for this uploader

Overrides:
uploadProgress in class AjaxFileUpload

autoSubmit

public Boolean autoSubmit()
Boolean which determines whether the upload should occur automatically after a file is selected.

Returns:
value for 'autoSubmit' binding

clearUploadProgressOnSuccess

public Boolean clearUploadProgressOnSuccess()

allowCancel

public Boolean allowCancel()

progressAmount

public Integer progressAmount()
Calculate the current progress amount ( 0-100 )

Returns:
current progress amount ( 0-100 )

refreshTime

public String refreshTime()
Returns the value for the binding 'refreshTime' The binding takes milliseconds between refreshes, this returns seconds

Returns:
value of the 'refreshTime' binding converted to seconds

uploadLabel

public String uploadLabel()
Label for the upload button

Overrides:
uploadLabel in class AjaxFileUpload
Returns:
string value for 'uploadLabel' binding

clearLabel

public String clearLabel()
Label for the clear button

Returns:
string value for 'clearLabel' binding

cancelLabel

public String cancelLabel()
Label for the cancel button

Returns:
string value for 'cancelLabel' binding

selectFileLabel

public String selectFileLabel()
Label for the select file button

Returns:
string value for 'selectFileLabel' binding

selectFileButtonClass

public String selectFileButtonClass()
CSS Class for the select file button

Returns:
string value for 'selectFileButtonClass' binding

uploadButtonClass

public String uploadButtonClass()
CSS Class for the upload file button

Returns:
string value for 'uploadButtonClass' binding

cancelButtonClass

public String cancelButtonClass()
CSS Class for the cancel upload button

Returns:
string value for 'cancelButtonClass' binding

clearButtonClass

public String clearButtonClass()
CSS Class for the clear upload button

Returns:
string value for 'clearButtonClass' binding

Last updated: Wed, Feb 22, 2012 • 07:00 AM EST

Copyright © 2002 – 2011 Project Wonder.