You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2008/08/29 16:37:10 UTC

svn commit: r690273 - /myfaces/trinidad/branches/1.2.9.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ExternalContextUtils.java

Author: matzew
Date: Fri Aug 29 07:37:10 2008
New Revision: 690273

URL: http://svn.apache.org/viewvc?rev=690273&view=rev
Log:
TRINIDAD-943 - handle session timeout

added getRequestedSessionId() and isRequestedSessionIdValid() to ExternalContextUtils, since JSF 1.x API is to poor for that.
These funcs will be used in the configurator, to handle the redirect on timeout.

Modified:
    myfaces/trinidad/branches/1.2.9.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ExternalContextUtils.java

Modified: myfaces/trinidad/branches/1.2.9.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ExternalContextUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.9.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ExternalContextUtils.java?rev=690273&r1=690272&r2=690273&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.9.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ExternalContextUtils.java (original)
+++ myfaces/trinidad/branches/1.2.9.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ExternalContextUtils.java Fri Aug 29 07:37:10 2008
@@ -24,6 +24,7 @@
 import javax.faces.context.ExternalContext;
 import javax.portlet.ActionRequest;
 import javax.portlet.PortletContext;
+import javax.portlet.PortletRequest;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletRequest;
 import javax.servlet.http.HttpServletRequest;
@@ -40,6 +41,42 @@
 {
 
   /**
+   * Returns the session ID for the client, or null if there is none.
+   *
+   * @param externalContext
+   * @return
+   */
+  public static String getRequestedSessionId(final ExternalContext externalContext)
+  {
+    if (isPortlet(externalContext))
+    {
+      return ((PortletRequest) externalContext.getRequest()).getRequestedSessionId();
+    }
+    else
+    {
+      return ((HttpServletRequest) externalContext.getRequest()).getRequestedSessionId();
+    }
+  }
+
+  /**
+   * Checks if the requested session ID is still valid
+   *
+   * @param externalContext
+   * @return
+   */
+  public static boolean isRequestedSessionIdValid(final ExternalContext externalContext)
+  {
+    if (isPortlet(externalContext))
+    {
+      return ((PortletRequest) externalContext.getRequest()).isRequestedSessionIdValid();
+    }
+    else
+    {
+      return ((HttpServletRequest) externalContext.getRequest()).isRequestedSessionIdValid();
+    }
+  }
+
+  /**
    * Returns the contextPath of the ServletContext or null for portlets
    *
    * @param externalContext