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 2010/07/15 00:14:49 UTC

svn commit: r964221 - in /myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces: application/PortletApplicationFactoryImpl.java application/PortletViewHandlerImpl.java context/PortletExternalContextImpl.java

Author: mfreedman
Date: Wed Jul 14 22:14:49 2010
New Revision: 964221

URL: http://svn.apache.org/viewvc?rev=964221&view=rev
Log:
PORTLETBRIDGE-154: ApplicationFactoryImpl should cache the Application instance it creates/returns

PORTLETBRIDGE-152:  Message attached to IllegalStateException from Bridge's ExternalContext.redirect needs to be improved

PORTLETBRIDGE-151: Bridge ViewHandler incompatible with Trinidad: if access as servlet restoreView fails to restore proper instance

Modified:
    myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletApplicationFactoryImpl.java
    myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java
    myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java

Modified: myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletApplicationFactoryImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletApplicationFactoryImpl.java?rev=964221&r1=964220&r2=964221&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletApplicationFactoryImpl.java (original)
+++ myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletApplicationFactoryImpl.java Wed Jul 14 22:14:49 2010
@@ -26,6 +26,7 @@ import javax.faces.application.Applicati
 public class PortletApplicationFactoryImpl extends ApplicationFactory
 {
   private ApplicationFactory mHandler;
+  private Application mPortletApplication;
   
   public PortletApplicationFactoryImpl(ApplicationFactory handler)
   {
@@ -34,7 +35,11 @@ public class PortletApplicationFactoryIm
   
   public Application getApplication()
   {
-    return new PortletApplicationImpl(mHandler.getApplication());
+    if (mPortletApplication == null )
+    {
+      mPortletApplication = new PortletApplicationImpl(mHandler.getApplication());
+    }
+    return mPortletApplication;
   }
   
   public void setApplication(Application app)

Modified: myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java?rev=964221&r1=964220&r2=964221&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java (original)
+++ myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java Wed Jul 14 22:14:49 2010
@@ -88,24 +88,27 @@ public class PortletViewHandlerImpl exte
     // We recognize this EL expresion here and evaluate to a viewid
     // before delegating// Do nothing when not running in portlet request
     
-    if (BridgeUtil.isPortletRequest())
+    if (!BridgeUtil.isPortletRequest())
     {
-      /* Note: later versions of glassfish jsf append a / if not in the nav rule
-      * -- remove it if blocking the expression.
-      */
-      if (viewId.startsWith("/#"))
-      {
-        viewId = viewId.substring(1);
-      }
-      
-      if (viewId.startsWith("#"))
+      return super.getActionURL(context, viewId);
+    }
+
+    // else its a portlet request -- so handle it according to our rules
+    /* Note: later versions of glassfish jsf append a / if not in the nav rule
+    * -- remove it if blocking the expression.
+    */
+    if (viewId.startsWith("/#"))
+    {
+      viewId = viewId.substring(1);
+    }
+    
+    if (viewId.startsWith("#"))
+    {
+      // evaluate this as an EL expression
+      viewId = (String) context.getApplication().evaluateExpressionGet(context, viewId, String.class);
+      if (viewId == null)
       {
-        // evaluate this as an EL expression
-        viewId = (String) context.getApplication().evaluateExpressionGet(context, viewId, String.class);
-        if (viewId == null)
-        {
-          //TODO:  at least log an error.
-        }
+        //TODO:  at least log an error.
       }
     }
     
@@ -142,27 +145,30 @@ public class PortletViewHandlerImpl exte
     // before delegating
     // Do nothing when not running in portlet request
     
-    if (BridgeUtil.isPortletRequest())
+    if (!BridgeUtil.isPortletRequest())
+    {
+      return super.createView(facesContext, viewId);
+    }
+    
+    
+    // else its a portlet request -- so handle according to bridge rules
+    /* Note: later versions of glassfish jsf append a / if not in the nav rule
+    * -- remove it if blocking the expression.
+    */
+    if (viewId.startsWith("/#"))
     {
-      /* Note: later versions of glassfish jsf append a / if not in the nav rule
-      * -- remove it if blocking the expression.
-      */
-      if (viewId.startsWith("/#"))
-      {
-        viewId = viewId.substring(1);
-      }
-      
-      if (viewId.startsWith("#"))
+      viewId = viewId.substring(1);
+    }
+    
+    if (viewId.startsWith("#"))
+    {
+      // evaluate this as an EL expression
+      viewId = (String) facesContext.getApplication().evaluateExpressionGet(facesContext, viewId, String.class);
+      if (viewId == null)
       {
-        // evaluate this as an EL expression
-        viewId = (String) facesContext.getApplication().evaluateExpressionGet(facesContext, viewId, String.class);
-        if (viewId == null)
-        {
-          //TODO:  at least log an error.
-        }
+        //TODO:  at least log an error.
       }
     }
-    
 
     UIViewRoot viewRoot = null;
     

Modified: myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java?rev=964221&r1=964220&r2=964221&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java (original)
+++ myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java Wed Jul 14 22:14:49 2010
@@ -586,7 +586,7 @@ public class PortletExternalContextImpl
         String target = params.getParameter(JSF_TARGET_VIEWID_RENDER_PARAMETER);
         if (target == null)
         {
-          throw new IllegalStateException("Can't redirect during render to a NonFaces target: " + target);
+          throw new IllegalStateException("Can't redirect during render to a NonFaces target: " + url);
         }
       }
       getRequestMap().put(BridgeImpl.REDIRECT_VIEWPARAMS, params);