myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfreed...@apache.org
Subject svn commit: r900972 - in /myfaces/portlet-bridge/core/trunk: api/src/main/java/javax/portlet/faces/ impl/src/main/java/org/apache/myfaces/portlet/faces/context/ impl/src/main/java/org/apache/myfaces/portlet/faces/el/
Date Tue, 19 Jan 2010 21:45:39 GMT
Author: mfreedman
Date: Tue Jan 19 21:45:38 2010
New Revision: 900972

URL: http://svn.apache.org/viewvc?rev=900972&view=rev
Log:
PORTLETBRIDGE-108: Bridge FacesContext doesn't set the current instance context on ELContext
PORTLETBRIDGE-107: Portlet ELresolver throws nullProperty exception instead of returning null
PORTLETBRIDGE-106: Add support for portlet: syntax to ref current view (with scope)

Modified:
    myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/Bridge.java
    myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
    myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java
    myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/el/PortletELResolver.java

Modified: myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/Bridge.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/Bridge.java?rev=900972&r1=900971&r2=900972&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/Bridge.java (original)
+++ myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/Bridge.java Tue
Jan 19 21:45:38 2010
@@ -301,6 +301,16 @@
    */
   public static final String FACES_VIEW_PATH_PARAMETER = "_jsfBridgeViewPath";
 
+  
+  /** Special value recognized during <code>encodeActionURL</code> of a portlet:
url containing either
+   * the <code>_jsfBridgeViewId</code> or <code>_jsfBridgeViewPath</code>
parameter. 
+   * <code>encodeActionURL</code> recognizes this value as indicating it needs
to generate and
+   * encode an URL to the current JSF including its current state.  I.e. It not only
+   * encodes the link reference but also the existing render parameters so they can be carried
forward
+   * to reestablish the state.
+   */
+  public static final String FACES_USE_CURRENT_VIEW_PARAMETER = "_jsfBridgeCurrentView";
+
   /** Enumeration whose values describe the current portlet phase the bridge
    * is executing Faces within.
    */

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=900972&r1=900971&r2=900972&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
Tue Jan 19 21:45:38 2010
@@ -269,12 +269,13 @@
   @Override
   public String encodeActionURL(String url)
   {
+    FacesContext ctx = FacesContext.getCurrentInstance();
     String viewId = null, path = null;
-    boolean nonFacesAction = false;
     QueryString queryStr = null;
     int queryStart = -1;
     boolean isPortletURL = false;
-    Bridge.PortletPhase urlType = getPortletPhase();
+    boolean isPortletURLSelfReference = false;
+    Bridge.PortletPhase urlType = Bridge.PortletPhase.ACTION_PHASE;
 
     // First check to see if the special URI indicating we should encode
     // a Nonfaces target to just the current portlet (without an associated
@@ -282,7 +283,7 @@
     if (isPortletURL(url))
     {
       isPortletURL = true;
-      nonFacesAction = true;
+      
       //URL is of the form scheme:urlType?queryString
       // remove the scheme
       path = url.substring(url.indexOf(":")+ 1);
@@ -309,6 +310,28 @@
             + url);
         return url;
       }
+      
+      // We allow use of this syntax to reference another (or this) jsf page --
+      // For example if one wants to create a redisplay link for this page
+      // we recognize its a JSF page because it includes a QS parameter
+      // that references either the viewId or viewPath
+      String s = queryStr.getParameter(Bridge.FACES_VIEW_ID_PARAMETER);
+      String s1 = queryStr.getParameter(Bridge.FACES_VIEW_PATH_PARAMETER);
+      if (s != null && s.equals(Bridge.FACES_USE_CURRENT_VIEW_PARAMETER))
+      {
+        isPortletURLSelfReference = true;
+        // by removing the parameter we will rely on retaining the current view info based
on \
+        // the current render params
+        queryStr.removeParameter(Bridge.FACES_VIEW_ID_PARAMETER);
+      }
+      else if (s != null && s1.equals(Bridge.FACES_USE_CURRENT_VIEW_PARAMETER))
+      {
+        isPortletURLSelfReference = true;
+        // by removing the parameter we will rely on retaining the current view info based
on \
+        // the current render params
+        queryStr.removeParameter(Bridge.FACES_VIEW_PATH_PARAMETER);
+      }
+
     }
     else if (url.startsWith("#") || isExternalURL(url) || isDirectLink(url))
     {
@@ -357,7 +380,6 @@
       else
       {
         // URL points at non-Faces action
-        nonFacesAction = true;
         encodeNonFacesActionTarget(queryStr, path);
       }
     }
@@ -371,20 +393,13 @@
       RenderResponse renderResponse = (RenderResponse) getResponse();
       PortletURL actionURL = null;
       // Non-JSF actions are renderURLs as we merely dispatch to them
-      if (nonFacesAction)
+      if (urlType == Bridge.PortletPhase.ACTION_PHASE)
       {
-        if (isPortletURL && urlType == Bridge.PortletPhase.ACTION_PHASE)
-        {
-          actionURL = renderResponse.createActionURL();
-        }
-        else
-        {
-          actionURL = renderResponse.createRenderURL();
-        }
-      } 
+        actionURL = renderResponse.createActionURL();
+      }
       else
       {
-        actionURL = renderResponse.createActionURL();
+        actionURL = renderResponse.createRenderURL();
       }
 
       // Add parameters so they don't get lost
@@ -430,6 +445,23 @@
           actionURL.setParameter(param, queryStr.getParameter(param));
         }
       }
+      
+      // Carry forward render parameters if this is a portlet:url that references the current
view
+      if (isPortletURLSelfReference)
+      {
+        Map m = mOrigPortletRequest.getParameterMap();
+        Set<Map.Entry<String, String[]>> s = m.entrySet();
+        Iterator<Map.Entry<String, String[]>> i = s.iterator();
+        while (i.hasNext())
+        {
+          Map.Entry<String, String[]> entry = i.next();
+          // only add if not already added from above
+          if (queryStr.getParameter(entry.getKey()) == null)
+          {
+            actionURL.setParameter(entry.getKey(), entry.getValue());
+          }
+        }
+      }
 
       // TODO hack to workaround double encoding problem
       url = actionURL.toString();

Modified: myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java?rev=900972&r1=900971&r2=900972&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java
(original)
+++ myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java
Tue Jan 19 21:45:38 2010
@@ -128,7 +128,8 @@
     {
       Application app = getApplication();
       mElContext = new PortletELContextImpl(app.getELResolver());
-      mElContext.putContext(FacesContext.class, this);
+      // Use one set as current instance in case we are wrapped
+      mElContext.putContext(FacesContext.class, FacesContext.getCurrentInstance());
       UIViewRoot root = getViewRoot();
       if (null != root)
       {

Modified: myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/el/PortletELResolver.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/el/PortletELResolver.java?rev=900972&r1=900971&r2=900972&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/el/PortletELResolver.java
(original)
+++ myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/el/PortletELResolver.java
Tue Jan 19 21:45:38 2010
@@ -80,6 +80,12 @@
     @Override
     public Object getValue(ELContext context, Object base, Object property) throws ELException
     {
+      // only process if running in a portlet request
+      if (!BridgeUtil.isPortletRequest() || base != null)
+      {
+        return null;
+      }
+      
       // variable resolution is a special case of property resolution
       // where the base is null.
       if (property == null)
@@ -87,12 +93,6 @@
         throw new PropertyNotFoundException("Null property");
       }
       
-      // only process if running in a portlet request
-      if (!BridgeUtil.isPortletRequest() || base != null)
-      {
-        return null;
-      }
-      
       // Recognize whether we are resolving in a Faces context or JSP context 
       // as the resolution differs.  I.e. in the JSP context we defer to
       // its implicit object resolver to resolve the <portlet:defineObjects> objects.
@@ -293,17 +293,17 @@
 
     @Override
     public Class<?> getType(ELContext context, Object base, Object property) throws
ELException
-    {
-      if (property == null)
-      {
-        throw new PropertyNotFoundException("Null property");
-      }
-      
+    {    
       // only process if running in a portlet request
       if (!BridgeUtil.isPortletRequest() || base != null)
       {
         return null;
       }
+      
+      if (property == null)
+      {
+        throw new PropertyNotFoundException("Null property");
+      }
 
       int index = -1;
       // As these properties aren't writable in either the Faces or JSP resolver



Mime
View raw message