myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mat...@apache.org
Subject svn commit: r377428 - /myfaces/commons/trunk/src/main/java/org/apache/myfaces/portlet/PortletUtil.java
Date Mon, 13 Feb 2006 17:17:07 GMT
Author: matzew
Date: Mon Feb 13 09:17:06 2006
New Revision: 377428

URL: http://svn.apache.org/viewcvs?rev=377428&view=rev
Log:
moving portlet util to commons

Added:
    myfaces/commons/trunk/src/main/java/org/apache/myfaces/portlet/PortletUtil.java

Added: myfaces/commons/trunk/src/main/java/org/apache/myfaces/portlet/PortletUtil.java
URL: http://svn.apache.org/viewcvs/myfaces/commons/trunk/src/main/java/org/apache/myfaces/portlet/PortletUtil.java?rev=377428&view=auto
==============================================================================
--- myfaces/commons/trunk/src/main/java/org/apache/myfaces/portlet/PortletUtil.java (added)
+++ myfaces/commons/trunk/src/main/java/org/apache/myfaces/portlet/PortletUtil.java Mon Feb
13 09:17:06 2006
@@ -0,0 +1,49 @@
+package org.apache.myfaces.portlet;
+
+
+import javax.faces.context.FacesContext;
+import javax.portlet.RenderResponse;
+
+/**
+ * Static utility class for portlet-related operations.
+ *
+ * @author  Stan Silvert
+ */
+public final class PortletUtil {
+    
+        /** This flag is imbedded in the request.
+         *  It signifies to MyFaces that the request is coming from a portlet.
+         */
+        public static final String PORTLET_REQUEST_FLAG = 
+           PortletUtil.class.getName() + ".PORTLET_REQUEST_FLAG";
+    
+        /** Don't allow a new instance of PortletUtil */
+        private PortletUtil() {
+        }
+        
+        /**
+         * Determine if we are processing a portlet RenderResponse.
+         *
+         * @param facesContext The current FacesContext.
+         * @return <code>true</code> if we are processing a RenderResponse,
+         *         <code>false</code> otherwise.
+         */
+        public static boolean isRenderResponse(FacesContext facesContext) {
+            if (!isPortletRequest(facesContext)) return false;
+            
+            return facesContext.getExternalContext().getResponse() instanceof RenderResponse;
+        }
+        
+        /**
+         * Determine if we are running as a portlet.
+         *
+         * @param facesContext The current FacesContext.
+         * @return <code>true</code> if we are running as a portlet,
+         *         <code>false</code> otherwise.
+         */
+        public static boolean isPortletRequest(FacesContext facesContext) {
+            return facesContext.getExternalContext()
+                               .getSessionMap()
+                               .get(PORTLET_REQUEST_FLAG) != null;
+        }
+    }
\ No newline at end of file



Mime
View raw message