You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mf...@apache.org on 2014/01/07 23:08:59 UTC

svn commit: r1556376 - /myfaces/portlet-bridge/core/branches/WLP_10.3.5/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java

Author: mfreedman
Date: Tue Jan  7 22:08:58 2014
New Revision: 1556376

URL: http://svn.apache.org/r1556376
Log:
Added the Liferay Hack to the code as a customer was running into the issue using WLP producer from a liferay consumer.

Modified:
    myfaces/portlet-bridge/core/branches/WLP_10.3.5/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java

Modified: myfaces/portlet-bridge/core/branches/WLP_10.3.5/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/WLP_10.3.5/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java?rev=1556376&r1=1556375&r2=1556376&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/WLP_10.3.5/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java (original)
+++ myfaces/portlet-bridge/core/branches/WLP_10.3.5/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java Tue Jan  7 22:08:58 2014
@@ -110,7 +110,9 @@ public class PortletExternalContextImpl
   public static final String SERVLET_INCLUDED_PATHINFO_ATTRIBUTE = "javax.servlet.include.path_info";
   public static final String SERVLET_INCLUDED_SERVLETPATH_ATTRIBUTE = "javax.servlet.include.servlet_path";
 
-
+  // Hack to work (best) with existing releases of Liferay
+  private static final String LIFERAY_NAMESPACE_PREFIX_HACK = "lfr_";
+  
   private PortletContext mPortletContext;
   private PortletRequest mPortletRequest;
   private PortletResponse mPortletResponse;
@@ -1045,7 +1047,22 @@ public class PortletExternalContextImpl
 
   public String encodeNamespace(String s)
   {
-    return ((PortletResponse) mPortletResponse).getNamespace() + s;
+    {
+      // We support creating a dummy ExternalContext (before FacesContext established) but some ops aren't available
+      assert FacesContext.getCurrentInstance() != null;
+
+      // Supposedly if this attribute is present we are running in Liferay
+      if (getRequestMap().get("THEME_DISPLAY") == null)
+      {
+        return ((PortletResponse) mPortletResponse).getNamespace() + s;
+      }
+      else
+      {
+        // For liferay -- prefix with extra chars so they don't strip
+        return LIFERAY_NAMESPACE_PREFIX_HACK + 
+          ((PortletResponse) mPortletResponse).getNamespace() + s;
+      }
+    }
   }
 
   @Override