SilverStream
Application Server 3.5

com.sssw.shr.page
Class AgpFileUpload

java.lang.Object
 |
 +--com.sssw.shr.page.AgpTag
       |
       +--com.sssw.shr.page.AgpControlBase
             |
             +--com.sssw.shr.page.AgpFileUpload
All Implemented Interfaces:
AgiJavaScriptEnhanced, AgiPageControl, Cloneable, Externalizable, Serializable

public class AgpFileUpload
extends AgpControlBase

Control for uploading a file to the server from an HTML page. Note that this is non-standard HTML.

This control appears as a text field with an associated Browse button. The file name length can be restricted. The kinds of files listed may also be restricted according to MIME content types.

Properties:
Enable HTML Generation, Maximum Path Length, Name, Size
Events:
fileUploaded
See Also:
Serialized Form

Fields inherited from class com.sssw.shr.page.AgpTag
UNIT_PERCENT, UNIT_PIXEL
 
Constructor Summary
AgpFileUpload()
           
 
Method Summary
 void addAgiFileUploadListener(AgiFileUploadListener listener)
          Add a listener for file upload events from this control.
 String getAccept()
          Returns the MIME types acceptable for upload.
 byte[] getContent()
          Returns the file contents of the uploaded file as a byte array or null if no file has been uploaded.
 String getContentType()
          Returns the MIME type of the uploaded file as specified by the uploading browser.
 int getMaxLength()
          Returns the maximum length of the pathname that can be entered.
 String getOriginalPath()
          Returns the original pathname of the uploaded file as specified by the browser or null if no file has been uploaded.
 boolean hasFileBeenUploaded()
          Returns whether a file has been uploaded in this request.
 void removeAgiFileUploadListener(AgiFileUploadListener listener)
          Stop listening for file upload events.
 void setAccept(String mimedesc)
          Specifies the MIME types acceptable for upload.
 void setMaxLength(int maxlength)
          Sets the the maximum length of the pathname that can be entered.
 
Methods inherited from class com.sssw.shr.page.AgpControlBase
getName
 
Methods inherited from class com.sssw.shr.page.AgpTag
getBoolProperty, getEnableHTMLGeneration, getIntArrayProperty, getIntProperty, getIntPropertyUnit, getProperty, getStringArrayProperty, invalidateHTML, removeProperty, setEnableHTMLGeneration, setIntProperty, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods implemented from interface com.sssw.shr.page.AgiJavaScriptEnhanced
generateFunction, generateRepaintScript, generateScriptInitializers, getFunctionNameForMethod, getFunctionNames, getMethodNames, getScriptObjectName, isHTMLRepaintPending, isJavaScriptRepaintPending
 
Methods implemented from interface com.sssw.shr.page.AgiPageControl
generateHTML, getPrefix, notifyPageLoaded, notifyPageRequestBegin, notifyPageRequestEnd, notifyPostValue, notifyPostValues
 
Methods implemented from interface java.io.Externalizable
readExternal, writeExternal
 

Constructor Detail

AgpFileUpload

public AgpFileUpload()
Method Detail

getMaxLength

public int getMaxLength()
Returns the maximum length of the pathname that can be entered.
Example:
 		int maxLength = file1.getMaxLength();
 
See Also:
Maximum Path Length property, AgpFileUpload.setMaxLength(int maxlength)

setMaxLength

public void setMaxLength(int maxlength)
Sets the the maximum length of the pathname that can be entered.
Parameters:
maxlength - an int representing the maximum length.
Example:
 		file1.setMaxLength(260);
 
See Also:
Maximum Path Length property, AgpFileUpload.getMaxLength()

getAccept

public String getAccept()
Returns the MIME types acceptable for upload.
Usage:

The user's browser may limit the user's choice of files to upload based on this value.

Example:
 		String listOfMIMETypes = file1.getAccept();
 
See Also:
AgpFileUpload.setAccept(String mimedesc)

setAccept

public void setAccept(String mimedesc)
Specifies the MIME types acceptable for upload.
Parameters:
mimedesc - a comma separated list of MIME types.
Usage:

The user's browser may limit the user's choice of files to upload based on this value.

Example:
 		file1.setAccept("text/plain,text/html,image/gif");
 
See Also:
AgpFileUpload.getAccept()

getOriginalPath

public String getOriginalPath()
Returns the original pathname of the uploaded file as specified by the browser or null if no file has been uploaded.
Example:
 		String originalPath = file1.getOriginalPath();
 
See Also:
AgpFileUpload.getContent(), AgpFileUpload.getContentType()

getContentType

public String getContentType()
Returns the MIME type of the uploaded file as specified by the uploading browser. Returns null if no file has been uploaded.
Example:
 		String contentType = file1.getContentType();
 
See Also:
AgpFileUpload.getContent(), AgpFileUpload.getOriginalPath()

getContent

public byte[] getContent()
Returns the file contents of the uploaded file as a byte array or null if no file has been uploaded.
Example:
 		byte content[];
 		content = file1.getContent();
 
See Also:
AgpFileUpload.getContentType(), AgpFileUpload.getOriginalPath()

hasFileBeenUploaded

public boolean hasFileBeenUploaded()
Returns whether a file has been uploaded in this request.
Usage:

This result may not be valid until a Submit event is received or the pageGenerateHTML event fires.

Example:
 		if (file1.hasFileBeenUploaded())
 		{
 			// Do something with the file contents....
 		}
 

addAgiFileUploadListener

public void addAgiFileUploadListener(AgiFileUploadListener listener)
Add a listener for file upload events from this control.
Parameters:
listener - an instance of AgiFileUploadListener.
Example:
 		file1.addAgiFileUploadListener(myListener);
 
See Also:
AgpFileUpload.removeAgiFileUploadListener(AgiFileUploadListener listener)

removeAgiFileUploadListener

public void removeAgiFileUploadListener(AgiFileUploadListener listener)
Stop listening for file upload events.
Parameters:
listener - an instance of AgiFileUploadListener.
Example:
 		file1.removeAgiFileUploadListener(myListener);
 
See Also:
AgpFileUpload.addAgiFileUploadListener(AgiFileUploadListener listener)

SilverStream
Application Server 3.5