0

I have followed this tutorial from BalusC for FileUpload. but setter isn't getting called

jmj
  • 237,923
  • 42
  • 401
  • 438
  • Did you read the notice at the top of the article? That leads to [this answer](http://stackoverflow.com/questions/5418292/jsf-2-0-file-upload/5424229#5424229). So, are you following the tutorial or the Stackoverflow answer? – Vineet Reynolds Sep 15 '11 at 12:49
  • @Vineet: the difference is however pretty subtle. You only need other and more JARs for Tomahawk for JSF 2.0. – BalusC Sep 15 '11 at 12:56

1 Answers1

4

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 ExtensionsFilter is missing in web.xml or not properly mapped on the servlet name of the FacesServlet. This is mandatory in order to be able to parse the multipart/form-data request.

  • There is another filter in the request-response chain before the ExtensionsFilter which 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 in web.xml. Request bodies can be parsed only once, so the ExtensionsFilter would receive an empty request after such another filter.

  • There is another filter in the request-response chain before the ExtensionsFilter which has completely skipped the ExtensionsFilter by for example forwarding or redirecting the request.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • there was prettyfilter I swapped both of them still if I add `enc-type` it doesn't get submitted and if I remove that it gets submitted but no setter called – user946782 Sep 15 '11 at 13:14
  • You must keep the `enctype` 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. – BalusC Sep 15 '11 at 13:17