Fileupload and PrettyFaces and JSF 2.2 [duplicate]

I’ve found a solution for my problem.

The problem is the action attribute of the forms which are used for the upload.
PrettyFaces changes the action attribute to the new pretty-url.

If you change the action attribute to the real url (the one with .xhtml,.jsf,…) the fileupload works again and the allowCasualMultipartParsing=”true” entry in the context-file(tomcat) is not needed anymore.

To change the path place this script into the view (your xhtml-file; jquery needed):

<script type="text/javascript">
     $(document).ready(function() {
         $("form[enctype="multipart/form-data"]").attr("action","#{request.contextPath}/test/fileupload.xhtml");
    });
</script>

Now the fileupload is working for all of my files including the ones which not worked (even with allowCasualMultipartParsing=”true” solution).

Tested with Primefaces4.0 FileUpload-Component.

EDIT:
Is there any other better solution?

Leave a Comment