To make your Primefaces upload component work together with Prettyfaces semantic URLs
Do you have an application with Primefaces’ fileUpload component that suddenly stopped working when you start using Prettyfaces to provide semantic URLs as asked in this page?
If you do, maybe this recipe suits your needs!
As usual, make sure you define Primefaces upload filter in your web.xml or web-fragment.xml file. However, unlike what you usually need to do, in order to make it usable together with Prettyfaces, that filter needs to be associated to the dispatcher type “FORWARD”, as follows:
<filter> <filter-name>PrimeFaces FileUpload Filter</filter-name> <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class> ... init params - not shown for simplicity reasons </filter> <filter-mapping> <filter-name>PrimeFaces FileUpload Filter</filter-name> <servlet-name>Faces Servlet</servlet-name> <dispatcher>FORWARD</dispatcher> </filter-mapping>
Without the association of Primefaces’ filter to the “forward” dispatcher type, Prettyfaces filters do not let the upload filter from Primefaces to be able to process the request. So, if you do associate the upload filter to the forward dispatcher, the filter is now able to be invoked and process the request