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:
com.webobjects.appserver.WOActionResults, com.webobjects.foundation.NSKeyValueCoding, com.webobjects.foundation.NSKeyValueCoding.ErrorHandling, com.webobjects.foundation.NSKeyValueCodingAdditions, com.webobjects.foundation.NSValidation, java.io.Serializable, java.lang.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
           
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
           
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
com.webobjects.appserver.WOComponent._EventLoggingEnabler, com.webobjects.appserver.WOComponent.Event
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
com.webobjects.foundation.NSKeyValueCodingAdditions.DefaultImplementation, com.webobjects.foundation.NSKeyValueCodingAdditions.Utility
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCoding
com.webobjects.foundation.NSKeyValueCoding._BooleanFieldBinding, com.webobjects.foundation.NSKeyValueCoding._BooleanMethodBinding, com.webobjects.foundation.NSKeyValueCoding._FieldBinding, com.webobjects.foundation.NSKeyValueCoding._ForwardingBinding, com.webobjects.foundation.NSKeyValueCoding._KeyBinding, com.webobjects.foundation.NSKeyValueCoding._KeyBindingCreation, com.webobjects.foundation.NSKeyValueCoding._MethodBinding, com.webobjects.foundation.NSKeyValueCoding._NumberFieldBinding, com.webobjects.foundation.NSKeyValueCoding._NumberMethodBinding, com.webobjects.foundation.NSKeyValueCoding._ReflectionKeyBindingCreation, com.webobjects.foundation.NSKeyValueCoding.ErrorHandling, com.webobjects.foundation.NSKeyValueCoding.Null, com.webobjects.foundation.NSKeyValueCoding.UnknownKeyException, com.webobjects.foundation.NSKeyValueCoding.ValueAccessor
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSValidation
com.webobjects.foundation.NSValidation._MethodBinding, com.webobjects.foundation.NSValidation._ValidationBinding, com.webobjects.foundation.NSValidation.DefaultImplementation, com.webobjects.foundation.NSValidation.Utility, com.webobjects.foundation.NSValidation.ValidationException
 
Field Summary
protected  org.apache.log4j.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(com.webobjects.appserver.WOContext context)
           
 
Method Summary
protected  com.webobjects.foundation.NSArray<java.lang.String> _ajaxUploadData()
          Builds the array of required additional AjaxUpload data items (wosid, id).
protected  com.webobjects.foundation.NSArray<java.lang.String> _ajaxUploadOptions()
          Builds the array of AjaxUpload options
 java.lang.String ajaxUploadData()
          Returns a comma separated string of AjaxUpload data items.
 java.lang.String ajaxUploadOptions()
          Returns a comma separated string of AjaxUpload options.
 java.lang.String ajaxUploadScript()
          Generates the script to initialize a new AjaxUpload JS object
 void appendToResponse(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context)
           
 java.lang.Boolean autoSubmit()
          Boolean which determines whether the upload should occur automatically after a file is selected.
 java.lang.String cancelButtonClass()
          CSS Class for the cancel upload button
 java.lang.String cancelFunction()
          JS Function string to cancel the iframe upload (by changing it's src url).
 java.lang.String cancelLabel()
          Label for the cancel button
 com.webobjects.appserver.WOActionResults cancelUpload()
          Action called by the cancel upload button
 java.lang.String cancelUrl()
          Returns a closeHTTPSession DA action URL passed to the iframe to cancel the client-side upload
 java.lang.String clearButtonClass()
          CSS Class for the clear upload button
 com.webobjects.appserver.WOActionResults clearFileResults()
          Action called by the clear button, resets the uploader for a new file selection
 java.lang.String clearLabel()
          Label for the clear button
 void clearUploadProgress()
          Helper to reset the uploader and unregister the AjaxProgress object
 com.webobjects.appserver.WOActionResults containerRefreshed()
          Action called when the either update container refreshes
 boolean fileChosen()
          Has a file been selected, but the upload not started.
 java.lang.String fileName()
          Accessor for the local fileName
 java.lang.String fileNameId()
          Unique identifier for the fileName container
 java.lang.String iframeId()
          Unique identifier for the iframe generated by the AjaxUploader.js
 java.lang.String innerContainerRefreshFunction()
          JS Function called when the inner container refreshes
 java.lang.String innerUpdateContainerId()
          Unique identifier for the inner update container
 java.lang.String onChangeFunction()
          JS Function called when the AjaxUpload registers a change
 java.lang.String onCompleteFunction()
          JS Function called when the AjaxUploader is completes.
 java.lang.String onSubmitFunction()
          JS Function called when the AjaxUploader submits
 java.lang.String outerContainerRefreshCompleteFunction()
          JS Function called when the outer container refreshes
 java.lang.String outerUpdateContainerId()
          Unique identifier for the outer update container
 java.lang.String progressClass()
          Returns the css class for the progress bar ('AMFUProgressAmount' or 'AMFUProgressAmount AMFUProgressAmountIndeterminate')
 java.lang.String progressStyle()
          Returns a style string containing the width of the progress element
 java.lang.String refreshTime()
          Returns the value for the binding 'refreshTime' The binding takes milliseconds between refreshes, this returns seconds
 java.lang.String selectFileButtonClass()
          CSS Class for the select file button
 java.lang.String selectFileLabel()
          Label for the select file button
 void setFileName(java.lang.String fn)
          Setter for the local fileName
 boolean showClearButton()
          Is the upload completed.
 boolean showFileSelect()
          Is there no file?
 boolean showProgressBar()
          Is there an upload currently in progress.
 boolean showUploadButton()
          Controls whether the upload button is displayed (this only occurs when the autoSubmit binding is false)
 boolean showUploadStarting()
          Should the component show the upload starting text?
 java.lang.String startFunction()
          JS Function string to start the inner update container
 java.lang.String stopFunction()
          JS Function string to stop the inner update container
 java.lang.String submitUploadFunction()
          JS Function called by the manual submit button.
 java.lang.String uploadButtonClass()
          CSS Class for the upload file button
 java.lang.String uploadButtonId()
          Unique identifier for the select files button
 com.webobjects.appserver.WOActionResults uploadCanceled()
          Hook for add-in action called when an upload is canceled
 com.webobjects.appserver.WOActionResults uploadFailed()
          Hook for add-in action called when an upload fails
 java.lang.String uploadLabel()
          Label for the upload button
 java.lang.String uploadName()
          Unique identifier for the upload name
 AjaxUploadProgress uploadProgress()
          Returns the upload progress for this uploader
 com.webobjects.appserver.WOActionResults uploadSucceeded()
           
 
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
_associationWithName, _awakeInContext, _childTemplate, _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, sleep, takeValueForKey, takeValueForKeyPath, takeValuesFromRequest, template, templateWithHTMLString, templateWithName, toString, unableToSetNullForKey, validateTakeValueForKeyPath, validateValueForKey, validationFailedWithException, valueForBinding, valueForKey, valueForKeyPath
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected final org.apache.log4j.Logger log

testFlag

public boolean testFlag

state

public AjaxFlexibleFileUpload.UploadState state
Constructor Detail

AjaxFlexibleFileUpload

public AjaxFlexibleFileUpload(com.webobjects.appserver.WOContext context)
Method Detail

appendToResponse

public void appendToResponse(com.webobjects.appserver.WOResponse response,
                             com.webobjects.appserver.WOContext context)
Overrides:
appendToResponse in class AjaxFileUpload

ajaxUploadScript

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

Returns:
script to initialize a new AjaxUpload JS object

_ajaxUploadData

protected com.webobjects.foundation.NSArray<java.lang.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 java.lang.String ajaxUploadData()
Returns a comma separated string of AjaxUpload data items.

Returns:
comma separated string of AjaxUpload data items.

_ajaxUploadOptions

protected com.webobjects.foundation.NSArray<java.lang.String> _ajaxUploadOptions()
Builds the array of AjaxUpload options

Returns:
array of AjaxUpload options

ajaxUploadOptions

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

Returns:
comma separated string of AjaxUpload options.

startFunction

public java.lang.String startFunction()
JS Function string to start the inner update container

Returns:
string to start the inner update container

stopFunction

public java.lang.String stopFunction()
JS Function string to stop the inner update container

Returns:
string to stop the inner update container

onChangeFunction

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

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

onCompleteFunction

public java.lang.String onCompleteFunction()
JS Function called when the AjaxUploader is completes.

Returns:
string JS Function called when the AjaxUploader is completes.

onSubmitFunction

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

Returns:
string JS Function called when the AjaxUploader submits

innerContainerRefreshFunction

public java.lang.String innerContainerRefreshFunction()
JS Function called when the inner container refreshes

Returns:
string JS Function called when the inner container refreshes

outerContainerRefreshCompleteFunction

public java.lang.String outerContainerRefreshCompleteFunction()
JS Function called when the outer container refreshes

Returns:
string JS Function called when the outer container refreshes

submitUploadFunction

public java.lang.String submitUploadFunction()
JS Function called by the manual submit button.

Returns:
string JS Function called by the manual submit button.

cancelFunction

public java.lang.String cancelFunction()
JS Function string to cancel the iframe upload (by changing it's src url).

Returns:
string to cancel the iframe upload (by changing it's src url).

innerUpdateContainerId

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

Returns:
identifier for the inner update container

outerUpdateContainerId

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

Returns:
identifier for the outer update container

uploadButtonId

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

Returns:
identifier for the select files button

iframeId

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

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

fileNameId

public java.lang.String fileNameId()
Unique identifier for the fileName container

Returns:
identifier for the fileName container

uploadName

public java.lang.String uploadName()
Unique identifier for the upload name

Returns:
identifier for the upload name

cancelUrl

public java.lang.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

containerRefreshed

public com.webobjects.appserver.WOActionResults containerRefreshed()
Action called when the either update container refreshes

Returns:
results of action

cancelUpload

public com.webobjects.appserver.WOActionResults cancelUpload()
Action called by the cancel upload button

Returns:
results of action

clearFileResults

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

Returns:
results of action

uploadCanceled

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

Overrides:
uploadCanceled in class AjaxFileUpload
Returns:
results of action

uploadFailed

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

Overrides:
uploadFailed in class AjaxFileUpload
Returns:
results of action

uploadSucceeded

public com.webobjects.appserver.WOActionResults uploadSucceeded()
Overrides:
uploadSucceeded in class AjaxFileUpload

clearUploadProgress

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


showProgressBar

public boolean showProgressBar()
Is there an upload currently in progress.

Returns:
boolean if an upload currently in progress.

showFileSelect

public boolean showFileSelect()
Is there no file?

Returns:
boolean true if there no file

showClearButton

public boolean showClearButton()
Is the upload completed.

Returns:
boolean true if the upload is complete

showUploadStarting

public boolean showUploadStarting()
Should the component show the upload starting text?

Returns:
boolean should show the starting text

fileChosen

public boolean fileChosen()
Has a file been selected, but the upload not started.

Returns:
boolean true if a file has been chosen

showUploadButton

public boolean showUploadButton()
Controls whether the upload button is displayed (this only occurs when the autoSubmit binding is false)

Returns:
boolean controls whether the upload button is displayed

uploadProgress

public AjaxUploadProgress uploadProgress()
Returns the upload progress for this uploader

Overrides:
uploadProgress in class AjaxFileUpload

autoSubmit

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

Returns:
value for 'autoSubmit' binding

progressStyle

public java.lang.String progressStyle()
Returns a style string containing the width of the progress element

Returns:
string style applied to the progress element

progressClass

public java.lang.String progressClass()
Returns the css class for the progress bar ('AMFUProgressAmount' or 'AMFUProgressAmount AMFUProgressAmountIndeterminate')

Returns:
string class applied to the progress bar

refreshTime

public java.lang.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

fileName

public java.lang.String fileName()
Accessor for the local fileName

Returns:
string value of fileName

setFileName

public void setFileName(java.lang.String fn)
Setter for the local fileName

Parameters:
fn -

uploadLabel

public java.lang.String uploadLabel()
Label for the upload button

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

clearLabel

public java.lang.String clearLabel()
Label for the clear button

Returns:
string value for 'clearLabel' binding

cancelLabel

public java.lang.String cancelLabel()
Label for the cancel button

Returns:
string value for 'cancelLabel' binding

selectFileLabel

public java.lang.String selectFileLabel()
Label for the select file button

Returns:
string value for 'selectFileLabel' binding

selectFileButtonClass

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

Returns:
string value for 'selectFileButtonClass' binding

uploadButtonClass

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

Returns:
string value for 'uploadButtonClass' binding

cancelButtonClass

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

Returns:
string value for 'cancelButtonClass' binding

clearButtonClass

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

Returns:
string value for 'clearButtonClass' binding

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.