This question already has an answer here:
- Fileupload and PrettyFaces and JSF 2.2 [duplicate] 2 answers
we're using a Glassfish 4.0 with JSF 2.2 (Mojarra 2.2.0) and PrettyFaces 2.0.
When trying to upload a file using h:inputFile
with the corresponding form enctype="multipart/form-data"
, the form action is only fired if the page is called directy, but nothing happens if the pretty url is called. Many other questions have some similar issues (e.g. How to use PrimeFaces p:fileUpload? Listener method is never invoked or UploadedFile is null), but most of them seem to use PrimeFaces and have difficulties with the order of the filters etc. Since we want to keep the JSF method for uploading files, I'd like to know if there is a configuration of some filters of Mojarra that I might have missed.
The web.xml
does currently not contain any filter specs.
the jsf file contains only this form
<h:form enctype="multipart/form-data">
<h:inputFile value="#{fileModel.testFile}"/>
<h:commandButton value="Upload" action="#{fileModel.upload}"/>
</h:form>
and the backing bean looks like this
@ApplicationScoped
@Named
public class FileModel {
private Part testFile;
public Part getTestFile() {
return testFile;
}
public void setTestFile(Part testFile) {
this.testFile = testFile;
}
public void upload() {
System.out.println("File Data: " + testFile);
}
}
then, uncommenting these lines in the pretty-config.xml
will yield the error, while commenting them won't.
<url-mapping id="fileTest">
<pattern value="/file" />
<view-id value="/view/fileTest.xhtml" />
</url-mapping>
I think the problem might be described in this post by OCPSoft, but there doesn't seem to be a solution yet.