Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

commons-fileupload

 
James Ellis
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This sounds like a silly question but:
did you set your form's enctype to "multipart/form-data" ? And the method to POST ?
 
James Ellis
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic