users@glassfish.java.net

Re: ViewExpiredException not caught by handler

From: <glassfish_at_javadesktop.org>
Date: Tue, 26 May 2009 01:48:37 PDT

This problem cause conflict between richfaces/facelets/jsf libs.
Problem connected with post request.
if you click in the links after expired redirect to main page working is fine
just add in your fase listner beforePhase method

else if (!viewId.equals("/index.xhtml") && ex.getSessionMap().get("UserContext") == null) {
      ex.getSessionMap().put("expired", 1);
      NavigationHandler nh = context.getApplication().getNavigationHandler();
      nh.handleNavigation(context, null, "logout");

-----------------
faces config.

<navigation-rule>
    <from-view-id>*</from-view-id>
    <navigation-case>
      <from-outcome>logout</from-outcome>
      <to-view-id>/index.xhtml</to-view-id>
      <redirect/>
    </navigation-case>
</navigation-rule>
--------------------------------------
Now if you click in buttons..........

........ this problem can be resolved by this way.
in the web.xml

 <context-param>
    <param-name>facelets.DEVELOPMENT</param-name>
    <param-value>false</param-value>
  </context-param>
  
  <!-- MyFaces Configuration -->
  <context-param>
    <param-name>org.apache.myfaces.ERROR_HANDLING</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.COMPRESS_STATE_IN_SESSION</param-name>
    <param-value>false</param-value>
  </context-param>
  <context-param>
    <param-name>org.apache.myfaces.CONFIG_REFRESH_PERIOD</param-name>
    <param-value>0</param-value>
  </context-param>

<error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/errorpages/viewexpire.jsp</location>
  </error-page>

----------------------------
viewexpire.jsp

<%@ page isErrorPage="true" %>
<% response.sendRedirect(request.getContextPath()+"/index.jsf?expired") ; %>

----
index.xhtml/jsf
<h:outputText value="#{log.expired}" rendered="#{param.expired != null}"/>
Thats All, 
You can not catch this exception but can solve the problem.
We must wait richfaces next releases, last version(3.3.1)- till have this problem(3).
[Message sent by forum member 'armen2010' (armen2010)]
http://forums.java.net/jive/thread.jspa?messageID=347643