0 Replies Latest reply on Feb 10, 2009 11:34 AM by Herbert Dowalil

    ajax4jsf and session timeout

    Herbert Dowalil Newbie

      hi everyone!

      i´ve added a phaselistener to recognize a timed out session and it works fine for non-ajax requests. it looks like this:

      FacesContext facesCtx = event.getFacesContext();
      ExternalContext extCtx = facesCtx.getExternalContext();
      HttpSession session = (HttpSession) extCtx.getSession(false);
      boolean newSession = (session == null) || (session.isNew());
      boolean postback = !extCtx.getRequestParameterMap().isEmpty();
      boolean timedout = postback && newSession;
      if (timedout) {
      Application app = facesCtx.getApplication();
      ViewHandler viewHandler = app.getViewHandler();
      UIViewRoot view = viewHandler.createView(facesCtx,url);
      try {
      viewHandler.renderView(facesCtx, view);
      } catch (Throwable t) {
      throw new FacesException("Session timed out", t);

      actually, this does not work for a4j requests, as only parts of the application are rerendered. what can i do? it seems that the dead session is recognized by the phase-listener on an ajax-request as well, but as the client only rerenders part of the page nothing happens. it is not visible for the user, he is not redirected to the session-timeout-page. so what can i do?

      thank you in advance,