we use Glassfish 4.0 with JSF 2.2 (Mojarra 2.2.0) and PrettyFaces 2.0. When you try to upload a file using h:inputFile with the corresponding form enctype="multipart/form-data" the form action is only triggered if the page is called directy, but nothing happens if a nice url is called. Many other questions have some similar problems (for example, How to use PrimeFaces p: fileUpload? The listener method is never called, and UploadedFile is null ), but most of them seem to use PrimeFaces and have difficulty ordering the filters, etc. Since we want to keep the JSF method for uploading files, I would like to know if there is some configuration of some Mojarra filters that I could skip.
web.xml currently does not contain filter specifications.
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 bean support is as follows
@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 pretty-config.xml will result in an error, while commenting them out will not.
<url-mapping id="fileTest"> <pattern value="/file" /> <view-id value="/view/fileTest.xhtml" /> </url-mapping>
I think the problem can be described in this post from OCPSoft, but there is no solution yet.
source share