aspose file tools*
The moose likes JSF and the fly likes commons-fileupload Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "commons-fileupload" Watch "commons-fileupload" New topic
Author

commons-fileupload

James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
I have a strange situation where the components on a form are dynamically built and the form is submitted to an action method "create" on a Controller class. Basically the form looks like this:

HtmlPanelGrid
(ROW 1)
--HtmlOutputText
--HtmlPanelGrid
----HtmlSelectOneRadio
----HtmlInputFileUpload
(ROW 2)
--HtmlOutputText
--HtmlPanelGrid
----HtmlSelectOneRadio
----HtmlInputText



Once form is submitted from the "create" method on the Controller class I can lookup the values of the HtmlInputText by doing:



However, I cannot figure out how to access the file that was submitted (the HtmlInputFileUpload). I tried using commons-fileupload as below:



but the items.size() is always zero. I am thinking JSF is intercepting this form before I pass it to the "parse" method and somehow this makes the form un-parsable" for commons-fileupload. If this is true...how can I get the file that was submitted before JSF messes with it...or better yet, how can I get the file that was submitted directly from JSF?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

This sounds like a silly question but:
did you set your form's enctype to "multipart/form-data" ? And the method to POST ?


[My Blog]
All roads lead to JavaRanch
James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
I've set the enctype to "multipart/form-data" and it looks like (when I view source) the method is already post.
James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
I know the file is getting uploaded because if I choose an extremely large file in the error logs I see:



So it's being uploaded to somewhere...only I can't figure out where the MultipartRequestWrapper is putting it. Any ideas?

PS - I've tried all of the following and none of them seem to contain the key for the file upload component.

James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
If I can't figure this one out soon...I will be forced to switch to scriptlets. Just to recap

Basically I have all these input type="file" form elements on a page that are created dynamically through a backing bean when a page loads. I can't create <t:inputFileUpload> tags and map each of them to a bean since they are dynamically created. So...I have tried to use commons-fileupload in the action method of my controller class (where the page submits) but it looks like by the time the action method is reached the MyfacesExtensionsFilter is messing up the request (because the commons-fileupload can't find any form elements when it parses the request).

Does anyone else have any suggestions or know how to get the file that was submitted from JSF? I know it has access to it because if I try and upload a file too large it throws an error message (see previous post for error message).

Jim
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Your file seems to be too big. Have a look at the following page about how to extend the allowed max size :
http://jakarta.apache.org/commons/fileupload/using.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: commons-fileupload