Back to home page.

How to Use the FileUpload Component

Mark Basler
Status: In Early Access

The in-screen-fileupload component consists of a form that is uploaded in the background using AJAX through the Dojo libraries.  The contents of the in-screen-fileupload form is configured  through the body of the JSF tag.  The tag library for the fileupload component can be accessed using the declaration <%@taglib prefix="ui" uri="http://java.sun.com/blueprints/ui" %>.

An example of the JSF fileupload component's use is as follows:

<ui:fileUploadTag id="TestFileuploadForm0" retFunction="testRetFunction" retMimeType="text/xml"
postProcessingMethod="#{FileUploadProcessing.postProcessingMethod}"
progressBarDivId="progress" progressBarSubmitId="submit1x" progressBarSize="40">
<input type="file" size="40" name="fileToUpload0" id="fileToUpload0Id"/><br>
<input type="file" size="40" name="fileToUpload1" id="fileToUpload1Id"/><br>
<input type="file" size="40" name="fileToUpload2" id="fileToUpload2Id"/><br>
<input type="submit" name="submit1x" value="Submit"/>
<div id="progress"></div><br/>
</ui:fileUploadTag>

Above, the component tag name is "fileUploadTag", that has the following attributes added to a traditional HTML form component's attributes:
 <response>
<message>File Upload has Completed Successfully!</message>
<status>COMPLETED</status>
<duration>188</duration>
<duration_string>0.188 seconds </duration_string>
<start_date>Wed Jan 25 12:21:58 PST 2006</start_date>
<end_date>Wed Jan 25 12:21:58 PST 2006</end_date>
<upload_size>67817</upload_size>
</response>

 

The FileUpload JSF component utilized Dojo and Apache Commons Fileupload & IO  third party libraries to provide JavaScript and Multi-part Mime parsing functionality.  A com.sun.javaee.blueprints.components.ui.fileupload.FileUploadStatus instance is placed in the user's session once the file upload starts under the key "fileuploadStatus".  It holds the current and completed status of the form being uploaded.

NOTE: The fileUploadTag must have the "enctype" attribute set to "multipart/form-data" to upload files.




Back to home page.

© Sun Microsystems 2006. All of the material in The Java BluePrints Solutions Catalog is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.