RichFaces spacer gif URL wrong after upgrade to JBoss 8 (WildFly) - jsf

I'm doing an upgrade from JBoss 6 to JBoss 8 (WildFly). The version of RichFaces 3.3.3 has stayed the same. Several places in the code call the RichText spacer, like this:
<rich:spacer height="15" width="5"/>
In web.xml, the servlet-mapping entries related to Faces looked like this:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
When running JBoss 6, the spacer image had the following URL, which worked fine:
https://host.com/dc/a4j/g/3_3_3.Finalimages/spacer.gif
We start running into issues when we upgrade to JBoss 8. The URL suddenly looks like this, and returns a 404 Not Found when accessed:
https://host.com/dc/faces/a4j/g/3_3_3.Finalimages/spacer.gif
I tried removing all but the *.jsf servlet-mapping from web.xml, like the documentation specifies. This made the URL look like this:
https://host.com/dc/a4j/g/3_3_3.Finalimages/spacer.gif.jsf
The URL returns a 500 Internal Server Error when accessed:
ERROR [io.undertow.request] (default task-29) UT005023: Exception handling request to /dc/a4j/g/3_3_3.Finalimages/spacer.gif.jsf: javax.servlet.ServletException: org.ajax4jsf.resource.ResourceNotFoundException: Resource not registered : images/spacer.gif.jsf
The image is always available the original URL.
For reference, here is web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>[clipped]</display-name>
<context-param>
<param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name>
<param-value>mojarra-1.2_15</param-value>
</context-param>
<context-param>
<param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
<param-value>com.sun.facelets.FaceletViewHandler</param-value>
</context-param>
<context-param>
<param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.jboss.seam.core.init.debug</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>Disable MyFacesExtensionsFilter check</description>
<param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.LoadStyleStrategy</param-name>
<param-value>NONE</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.LoadScriptStrategy</param-name>
<param-value>NONE</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.numberOfViewsInSession</param-name>
<param-value>5</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.numberOfLogicalViews</param-name>
<param-value>5</param-value>
</context-param>
<servlet>
<servlet-name>Seam Resource Servlet</servlet-name>
<servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Seam Resource Servlet</servlet-name>
<url-pattern>/seam/resource/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>Seam Filter</filter-name>
<filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
</filter>
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>Seam Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<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>*.jsf</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>45</session-timeout>
</session-config>
</web-app>
I just assume bypass the issue and do away with the spacer, but the spacer is also called internally by RichFaces, within some of the components that we are currently using.
What should I do to get the spacer to show up correctly?

You should exclude second initialization of org.ajax4jsf.Filter in filter and filter-mapping sections of web.xml. Seam instantiate org.ajax4jsf.Filter from Ajax4jsfFilterInstantiator class.
Please remove following code from web.xml
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
...
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
See related RichFaces Issue RF-3410

Related

Error loading css, cannot find "theme.css" resource of "primefaces-Omega" library Primefaces 6.0

I'm using PrimeFaces 6.0 on JSF 2.2 in order to benefit from the new built-in free community theme Omega, however it's doesn't work for me.
In the documentation it's said "To enable omega, set primefaces.THEME context parameter to Omega and that’s it"
I'm not using a maven project
here is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>Omega</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
<param-value>true</param-value>
</context-param>
<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>
<session-config>
<session-timeout>
18000
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>login.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>primefaces.UPLOADER</param-name>
<param-value>commons</param-value>
</context-param>
<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>
</filter-mapping>
In the primefaces official blog it's written Omega with a capital "O"
hhhh it works by changing it to omega.

Removing /faces/ from URL in JSF applications

I have made website using JSF 2.0
All links goes as below.
http://www.mywebsite.com/faces/index.xhtml
What I want is remove /faces/, so that final url would be as below.
http://www.mywebsite.com/index.xhtml
Note: I want to achieve this while passing parameters.
This question is related to my previous question
What I tried is changing filter criteria for my new filter
<filter>
<filter-name>UrlRewrite</filter-name>
<filter-class>com.lab.filter.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewrite</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
TO
<filter>
<filter-name>UrlRewrite</filter-name>
<filter-class>com.lab.filter.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewrite</filter-name>
<url-pattern>/</url-pattern> // here made change from /* to /
</filter-mapping>
But it was giving errors. No web page is showing.
What I want to achieve from previous is mywebsite.com/faces/dr.rajesh to mywebsite.com/dr.rajesh
Full WEB-INF as below.
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<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>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
<filter>
<filter-name>restrict</filter-name>
<filter-class>com.lab.filter.MyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>restrict</filter-name>
<url-pattern>*.xhtml</url-pattern>
</filter-mapping>
<filter>
<filter-name>MyFacesExtensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>none</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.enableRestoreView11Compatibility</param-name>
<param-value>true</param-value>
</context-param>
<filter>
<filter-name>UrlRewrite</filter-name>
<filter-class>com.lab.filter.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewrite</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
In your web.xml you just need the url pattern below:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
and remove the other mapping to the Faces Servlet.
In modern JSF versions (>2.1), you don't need any entries in the web.xml at all since the are present 'on' the Faces Servlet via annotations and will be parsed.
Remove the below content from WEB-INF web.xml
<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>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>

rich:fileUpload randomly fails with "Transfer failed" error

I am using <rich:fileUpload> of RichFaces 3.3.3 Final. When I upload some Excel files in Chrome browser, then it sometimes shows the "Transfer failed" error message as in below screenshot:
Sample Code,
<rich:fileUpload id="fileUpload" addControlLabel="#{bundle.browse}"
allowFlash="#{not TestFileUpload.allow}"
fileUploadListener="#{TestFileUpload.fileUploadListener}"
maxFilesQuantity="10"
autoclear="false"
listHeight="135px;"
uploadControlLabel="#{bundle.upload}"
progressLabel="#{bundle.progress}"
sizeErrorLabel="#{bundle.sizeError}"
noDuplicate="true"
style="width: 100%; height: 135px;">
<a4j:support event="onuploadcomplete"
onbeforedomupdate=""
action="#{TestFileUpload.validateExcel}"
reRender="validationDetailPanelId, messageId"
focus="cancelId"/>
</rich:fileUpload>
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>
<param-value>true</param-value>
</context-param>
<!--Configuration for Facelets-->
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.jsp</param-value>
</context-param>
<context-param>
<param-name>
facelets.RECREATE_VALUE_EXPRESSION_ON_BUILD_BEFORE_RESTORE
</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_VIEW_MAPPINGS</param-name>
<param-value>*.xhtml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.verifyObjects</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.LoadStyleStrategy</param-name>
<param-value>all</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.LoadScriptStrategy</param-name>
<param-value>all</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<context-param>
<param-name>org.ajax4jsf.SKIN</param-name>
<param-value>Wine</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
<param-value>enable</param-value>
</context-param>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>
/WEB-INF/test/faces-config.xml
</param-value>
</context-param>
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>Ajax4jsf</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
<init-param>
<param-name>enable-cache</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>createTempFiles</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>maxRequestSize</param-name>
<param-value>1048576</param-value>
</init-param>
</filter>
<filter>
<filter-name>SFilter</filter-name>
<filter-class>com.test.SFilter</filter-class>
</filter>
<listener>
<display-name>SLCListener</display-name>
<listener-class>com.test.SLCListener</listener-class>
</listener>
<!-- End of Rich Faces and A4JSF -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>Custom Faces Servlet</servlet-name>
<servlet-class>com.test.CFServlet</servlet-class>
<init-param>
<param-name>error</param-name>
<param-value>/faces/pages/errorPage.jsp</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<servlet-name>ASServlet</servlet-name>
<servlet-class>com.test.ASServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>PASRServlet</servlet-name>
<servlet-class>com.test.PASRServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>LOServlet</servlet-name>
<servlet-class>com.test.LOServlet</servlet-class>
<init-param>
<param-name>DException</param-name>
<param-value>/faces/pages/dException.jsp</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<servlet-name>FDServlet</servlet-name>
<servlet-class>com.test.FDServlet</servlet-class>
</servlet>
<!--OverRiding FacesServlet Start-->
<servlet-mapping>
<servlet-name>Custom Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Custom Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
<!--Filter for ajaxrequest and Custom Faces Servlet-->
<filter-mapping>
<filter-name>Ajax4jsf</filter-name>
<servlet-name>Custom Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>SSEFilter</filter-name>
<servlet-name>Custom Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>
<!--End-->
<!-- Filter for Commons File Upload -->
<filter>
<filter-name>Extensions Filter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
<init-param>
<param-name>uploadMaxFileSize</param-name>
<param-value>20m</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Extensions Filter</filter-name>
<servlet-name>Custom Faces Servlet</servlet-name>
</filter-mapping>
<!-- End of commons file upload filter -->
<error-page>
<error-code>404</error-code>
<location>/faces/pages/error/errorPage.jsp</location>
</error-page>
</web-app>
The file is also not being uploaded to the server. How is this caused and how can I solve it?
i have the same problem since one of the lastest update of Chrome.
Chrome version : 36
The fileUploadListener method in the bean is called twice when you click on the upload button.
The debug mode reveals that The second time, the file is lost.
I bypassed the problem like that :
public void fileUploadListener(UploadEvent event) {
if(!event.getUploadItem().getFileName().equalsIgnoreCase("")){
//code here
}
}
First make your bean session scope then in web.xml change boolean attribute of createTempFiles to false instead of true just as below:
<init-param>
<param-name>createTempFiles</param-name>
<param-value>false</param-value>
</init-param>

Web Filter blocking RichFaces

I create a filter and it works fine but my richfaces doesn't work correctly anymore, here is my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>SuaParte</display-name>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
<param-value>enable</param-value>
</context-param>
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<context-param>
<param-name>com.sun.faces.disableVersionTracking</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
<param-value>true</param-value>
</context-param>
<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>
<filter>
<filter-name>LoginFilter</filter-name>
<filter-class>filter.LoginFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>LoginFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
</web-app>
I also try the #BalusC suggestion here, changing the web.xml to:
<filter>
<filter-name>LoginFilter</filter-name>
<filter-class>filter.LoginFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>LoginFilter</filter-name>
<url-pattern>/secured/*</url-pattern>
</filter-mapping>
And change the *.xhtml files to a secured folder :
But this way the filter doesn't work anymore.
How can I make the richfaces work with my filter ?
RichFaces resources are also passed through the FacesServlet and thus also through your security filter. You need to add an extra if check to bypass resource requests (read: CSS/JS/image requests done by <h:outputStylesheet>, <h:outputScript>, <h:graphicImage>, etc, either explicitly declared in markup or implicitly added by JSF/RichFaces).
String uri = ((HttpServletRequest) request).getRequestURI();
// Ignore JSF2/RF4 resources (which are also mapped on FacesServlet).
if (uri.startsWith(ResourceHandler.RESOURCE_IDENTIFIER) || uri.startsWith(ResourceHandlerImpl.RICHFACES_RESOURCE_IDENTIFIER)) {
chain.doFilter(request, response);
return;
}
// ...
with
import javax.faces.application.ResourceHandler;
import org.richfaces.resource.ResourceHandlerImpl;
As to why your /secured/* mapping doesn't work is because you've one extra /pages path there in your folder structure. The filter should then be mapped on /pages/secured/*.

faces-redirect=true in JSF

I am using the ?faces-redirect=true in my JSF2, since I would like to redirect the user so the URL will be changed.
In JSF1.2 I added </redirect> in faces-config.
In JSF2 I have to add to my url return home?faces-redirect=true.
The problem is that I see faces-redirect=2 in the URL, what I haven't seen in JSF1.2 when I used </redirect>
How can I use faces-redirect in actions without displaying it in the browser URL?
My Jar's list:
antlr-2.7.6.jar
aopalliance-1.0.jar
aspectjrt.jar
atmosphere-compat-tomcat-0.5.jar
atmosphere-runtime-0.5.jar
commons-beanutils-1.7.0.jar
commons-collections-3.2.jar
commons-dbcp-1.2.2.jar
commons-digester-2.0.jar
commons-fileupload-1.2.1.jar
commons-httpclient-3.1.jar
commons-io-1.4.jar
commons-logging-1.1.1.jar
commons-pool-1.5.4.jar
dom4j.jar
ehcache-1.2.4.jar
hibernate-annotations.jar
hibernate-cglib-repack-2.1_3.jar
hibernate-commons-annotations.jar
hibernate3.jar
itext-1.4.8.jar
javassist.jar
javax.persistence.jar
jhighlight-1.0.jar
jsf-api.jar
jsf-impl.jar
jstl-api-1.2.jar
jstl-impl-1.2.jar
jta-1.1.jar
log4j-1.2.15.jar
mail.jar
mysql-connector-java-5.1.0-bin.jar
org.springframework.aop-3.0.1.RELEASE-A.jar
org.springframework.asm-3.0.1.RELEASE-A.jar
org.springframework.aspects-3.0.1.RELEASE-A.jar
org.springframework.beans-3.0.1.RELEASE-A.jar
org.springframework.context-3.0.1.RELEASE-A.jar
org.springframework.context.support-3.0.1.RELEASE-A.jar
org.springframework.core-3.0.1.RELEASE-A.jar
org.springframework.expression-3.0.1.RELEASE-A.jar
org.springframework.instrument-3.0.1.RELEASE-A.jar
org.springframework.instrument.tomcat-3.0.1.RELEASE-A.jar
org.springframework.jdbc-3.0.1.RELEASE-A.jar
org.springframework.jms-3.0.1.RELEASE-A.jar
org.springframework.orm-3.0.1.RELEASE-A.jar
org.springframework.oxm-3.0.1.RELEASE-A.jar
org.springframework.test-3.0.1.RELEASE-A.jar
org.springframework.transaction-3.0.1.RELEASE-A.jar
org.springframework.web-3.0.1.RELEASE-A.jar
org.springframework.web.portlet-3.0.1.RELEASE-A.jar
org.springframework.web.servlet-3.0.1.RELEASE-A.jar
org.springframework.web.struts-3.0.1.RELEASE-A.jar
poi-3.2-FINAL.jar
primefaces-2.0.3-SNAPSHOT.jar
slf4j-api-1.5.11.jar
slf4j-log4j12-1.5.11.jar
spring-aop.jar
My web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>OnBoard</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<description></description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/applicationContext.xml
classpath:/applicationContext-security.xml
</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.forceLoadConfiguration</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>facelets.BUILD_BEFORE_RESTORE</param-name>
<param-value>false</param-value>
</context-param>
<filter>
<filter-name>Security Page Filter</filter-name>
<filter-class>com.mycompany.servlet.SecurityFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Security Page Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</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>
</filter-mapping>
<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>*.jsf</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>org.primefaces.resource.ResourceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/primefaces_resource/*</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
This looks all fine. Something else is disturbing it. Maybe Spring? I don't do Spring so I can't tell anything about it. At least, it works fine here with Mojarra 2.0.2 + PrimeFaces 2.1 + Tomcat 6.0.24.
To nail this problem down anyway, consider creating a brand new web project with only jsf-api.jar and jsf-impl.jar files in the /WEB-INF/lib and two simple XHTML files with a <h:commandButton outcome="otherfile?faces-redirect=true" />. Then add libraries/components/mappings step by step until you get the same setup as the original project. Test the working of faces-redirect during every step. Keep track of what you've added so that you know what may have caused this problem.
That's not what I'm experiencing with Mojarra (the RI). If I return the following in a managed bean:
return "somepage" + "?faces-redirect=true";
JSF redirects to the target somepage view and the URL doesn't include the ?faces-redirect=true.
What implementation are you using?

Resources