8 Replies Latest reply on Apr 14, 2009 5:49 AM by alibsd

    A4J.AJAX.onExpired is not called

    alibsd

      Hi

      I'm having problem with redefining onExpired handler. I've searched all forum entries
      related to this method, but have not found any reason why this method is not called.

      I'm using JSP, RichFaces 3.3.0 GA and MyFaces 1.2.6. The web server is Apache Tomcat 6.
      The files which I think might be important are:

      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>expire</display-name>
       <welcome-file-list>
       <welcome-file>index.html</welcome-file>
       <welcome-file>index.htm</welcome-file>
       <welcome-file>index.jsp</welcome-file>
       <welcome-file>default.html</welcome-file>
       <welcome-file>default.htm</welcome-file>
       <welcome-file>default.jsp</welcome-file>
       </welcome-file-list>
       <context-param>
       <param-name>org.richfaces.SKIN</param-name>
       <param-value>blueSky</param-value>
       </context-param>
       <filter>
       <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>
       </filter-mapping>
       <context-param>
       <param-name>org.apache.myfaces.ERROR_HANDLING</param-name>
       <param-value>false</param-value>
       </context-param>
      
       <context-param>
       <param-name>org.ajax4jsf.handleViewExpiredOnClient</param-name>
       <param-value>true</param-value>
       </context-param>
      
       <session-config>
       <session-timeout>1</session-timeout>
       </session-config>
      
       <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>
      </web-app>
      


      test.jsp
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
      <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
      <html>
      <head>
      <script>
       A4J.AJAX.onError = function(req, status, message) {
       window.alert("Custom onError handler "+message);
       }
      
       A4J.AJAX.onExpired = function(loc, expiredMsg) {
       alert('XXXXXX');
       }
      }
      </script>
      </head>
      <f:view>
       <a4j:form id="form1">
       <h:outputText value="Enter your name:" id="prompt" />
      
       <h:inputText value="#{bean.name}" id="input_foo_text" />
      
       <h:outputText value="Hello #{bean.name}" id="greeting" />
       <a4j:commandButton value="Submit" id="submit_button" reRender="greeting" />
       </a4j:form>
      </f:view>
      </html>
      


      As you can see in web.xml, I've set the session timeout to 1 minute for test,
      if "submit" is clicked after 1 minute, just the exception is thrown in console
      and an error response is sent to the browser, but the handler is not called.

      Can someone please tell me what I've missed?

      Regards