Last updated January 14, 2009 16:31, by Jason Lee
Feedicon  
==<sc:multiFileUpload> - An Applet-based Mutilple File Upload Component== The multiFile upload component works around a limitation with the HTML "file" input control, namely that the user can only select one file per input field. The component does this by making use of a Java applet, which uses Swing's <code>JFileChooser</code> to allow the user to select an arbitrary number of files from a directory. Depending on the mode in which the component is rendered, the user can even select files from multiple directories. A sample invocation of the component might look like this: <textarea name="code" class="xml"><nowiki><sc:multiFileUpload maxFileSize="3145728" fileHolder="#{testBean.fileHolder}" destinationUrl="#{testBean.destination}" width="500px" height="250px" /></nowiki></textarea> Rendered on the page, it would look like this: [[image:multiFileUpload.png]] <code>sc:multiFileUpload</code> uses a <code>PhaseListener</code> to handle the file uploads, which takes each file upload and stores it in the <code>FileHolder</code> specified in the component markup. Scales provides a default implementation of the <code>FileHolder</code> interface, <code>com.sun.mojarra.scales.model.FileHolderImpl</code>, which simply takes the <code>byte[]</code> for each file and stores in in an internal <code>List</code>. Applications are free to implement their own <code>FileHolder</code>, for example, to take each file and store it in a database, write it to an app-specific location on disk, etc. Once all of the files have been processed, the broweser is redirected to <code>destionationUrl</code>, which can be a string literal or EL expression. If <code>destionationUrl</code> is a <code>MethodExpression</code>, this method can either just return the view name, or it can process the files uploaded and return different views depending on any validation done on the uploaded files, allowing the user to have an error page, for example. NOTE: This does *NOT* currently resolve a navigation case result string to the mapped view from the Faces configuration. This assumes that the string in question is the *name* of a view, so "success" will become [http://localhost:8080/MyContext/success.jsf], not [http://localhost:8080/MyContext/youdidit.jsf] that you may have mapped in your Faces config. This is due to the lack of a portable way of making that resolution, which should be fixed in JSF 2.
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close