<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 JFileChooser 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:
Rendered on the page, it would look like this:
sc:multiFileUpload uses a PhaseListener to handle the file uploads, which takes each file upload and stores it in the FileHolder specified in the component markup. Scales provides a default implementation of the FileHolder interface, com.sun.mojarra.scales.model.FileHolderImpl, which simply takes the byte[] for each file and stores in in an internal List. Applications are free to implement their own FileHolder, 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 destionationUrl, which can be a string literal or EL expression. If destionationUrl is a MethodExpression, 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.





