I have followed this tutorial from BalusC for FileUpload. but setter isn't getting called
-
Did you read the notice at the top of the article? That leads to this answer. So, are you following the tutorial or the Stackoverflow answer?Vineet Reynolds– Vineet Reynolds2011-09-15 12:49:20 +00:00Commented Sep 15, 2011 at 12:49
-
@Vineet: the difference is however pretty subtle. You only need other and more JARs for Tomahawk for JSF 2.0.BalusC– BalusC2011-09-15 12:56:46 +00:00Commented Sep 15, 2011 at 12:56
1 Answer
That can have the following causes:
The
enctype="multipart/form-data"attribute is missing on the<h:form>. This is mandatory in order to be able to send files to the server.The
ExtensionsFilteris missing inweb.xmlor not properly mapped on the servlet name of theFacesServlet. This is mandatory in order to be able to parse themultipart/form-datarequest.There is another filter in the request-response chain before the
ExtensionsFilterwhich has already parsed the multipart/form-data request beforehand. For example, when you're using RichFaces4, such a filter will be auto-loaded without that you need to declare it inweb.xml. Request bodies can be parsed only once, so theExtensionsFilterwould receive an empty request after such another filter.There is another filter in the request-response chain before the
ExtensionsFilterwhich has completely skipped theExtensionsFilterby for example forwarding or redirecting the request.
2 Comments
enc-type it doesn't get submitted and if I remove that it gets submitted but no setter calledenctype in the form. So, your concrete problem is that the form is not submitted at all? What exactly does not happen? Is the HTTP request not sent? Is the bean action method not invoked? Are you using Ajax to submit the form? You should not use Ajax for this. It has to be a plain vanilla synchronous form submit.