I using in my project PrimeFaces 5.3 with PrettyFaces 3.3.3. The problem what i got is upload file (ajax upload)
<p:fileUpload
fileUploadListener="#{userProductsView.handlePrimaryImageUpload}"
value="#{userProductsView.primaryImageTemp}"
process="@this"
auto="true"
mode="advanced"
label=" " />
and here is my prettyfaces configuration file (there is dynamic set view-id from manage bean)
<url-mapping id="global_login">
<pattern value="/logowanie" />
<view-id value="#{routesService.getViewPath}" />
</url-mapping>
and manage bean:
@RequestScoped // javax.enterprise.context.RequestScoped
@Named("routesService") // javax.inject.Named
public class RoutesService {
private Map<String, String> resources;
public String getView(String pattern) {
return resources.get(pattern);
}
public String getViewPath() {
String path = "/";
UrlMapping currentMapping = PrettyContext.getCurrentInstance().getCurrentMapping();
if (currentMapping != null) {
String pattern = currentMapping.getPattern();
if (pattern != null) {
String[] splited = pattern.split("/");
if (splited.length > 1) {
path = "/" + splited[1];
}
}
}
return getView(path);
}
}
i investigate that. when i not use dynamic view-id (through routesService) value from bean for example:
<url-mapping id="global_login">
<pattern value="/logowanie" />
<view-id value="/faces/logowanie.xhtml" />
</url-mapping>
the upload works fine. I trying to resolve problem but i dont have Idea what i could do. Can anyone help with that issue i will grateful for any help.
below I include some peace of my pom.xml and web.xml
web.xml:
<context-param>
<param-name>primefaces.UPLOADER</param-name>
<param-value>commons</param-value>
</context-param>
<!-- SERVLET -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<!-- FILTERS -->
<filter>
<filter-name>Pretty Filter</filter-name>
<filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Pretty Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>
org.primefaces.webapp.filter.FileUploadFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
and pom.xml:
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
ACCORDING TO BalusC comment:
I set filters in the following order and both filters have pattern /*:
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>
org.primefaces.webapp.filter.FileUploadFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter>
<filter-name>Pretty Filter</filter-name>
<filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Pretty Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
in that configurations upload not working. (before it worked on PrettyFaces rewrited urls but only on that urls when mapping to view-id was hardcoded not injected from managed bean). I need to inject view-id url from managed bean so from that is this issue. Seems the problem happen when PrettyFaces engine when he inject the path from managed bean