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 2009/09/03 19:24:29 UTC

svn commit: r811048 - /myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java

Author: mfreedman
Date: Thu Sep  3 17:24:29 2009
New Revision: 811048

URL: http://svn.apache.org/viewvc?rev=811048&view=rev
Log:
PORTLETBRIDGE-95:  Fix/commit for the Portlet 1.0 codeline

Modified:
    myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java

Modified: myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java?rev=811048&r1=811047&r2=811048&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java (original)
+++ myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java Thu Sep  3 17:24:29 2009
@@ -119,6 +119,7 @@
   private static final String REQUEST_PARAMETERS = "org.apache.myfaces.portlet.faces.includeInScope.requestParameters";
   private static final String PREEXISTING_ATTRIBUTE_NAMES = "org.apache.myfaces.portlet.faces.preExistingAttributeNames";
   private static final String REQUEST_SCOPE_ID_RENDER_PARAM = "__jpfbReqScopeId";
+  private static final String NULL_VIEW_STATE_PARAM_VALUE = "org.apache.myfaces.portlet.faces.nullViewState";
   private static final int DEFAULT_MAX_MANAGED_REQUEST_SCOPES = 100;
 
   private Boolean mPreserveActionParams = Boolean.FALSE;
@@ -1025,16 +1026,30 @@
     Map<String, Object> requestMap = ec.getRequestMap();
     Map<String, String[]> requestParameterMap = ec.getRequestParameterValuesMap();
     if (mPreserveActionParams.equals(Boolean.FALSE))
-    {
-      if (requestMap != null && requestParameterMap != null && 
-          requestParameterMap.containsKey(ResponseStateManager.VIEW_STATE_PARAM))
       {
         Map<String, String[]> m = new HashMap<String, String[]>(1);
-        m.put(ResponseStateManager.VIEW_STATE_PARAM, 
-              requestParameterMap.get(ResponseStateManager.VIEW_STATE_PARAM));
+        if (requestParameterMap != null && 
+            requestParameterMap.containsKey(ResponseStateManager.VIEW_STATE_PARAM))
+        {
+          m.put(ResponseStateManager.VIEW_STATE_PARAM, 
+                requestParameterMap.get(ResponseStateManager.VIEW_STATE_PARAM));
+        } 
+        else
+        {
+          // Manufacture a dummy VIEW_STATE_PARAM so Faces will see the render as being in a Postback
+          // Issue this resolves is as follows:  Faces CommandLinks/Trinidad GoLinks are direct (href) links
+          // to JSF views.  They are encoded as action URLs but generally submitted as GETs (without VIEW_STATE param)
+          // When we fall through to the render following this action, the view is restored from cache (as usual)
+          // and then we call lifecycle.execute.  The Faces RI (Mojarra) unfortunately has code in its restoreView handler
+          // that if the UIViewRoot is already restored and isPostback is false (no VIEW_STATE param), then it sets 
+          // responseComplete.  By doing so the lifecycle.render is skipped and we get no markup output.
+          // By creating a dummy VIEW_STATE param we work around this -- and as this parameter is updated at the end of the
+          // render with the real one (because a save occurs) it shouldn't get out of sync with the cache view.
+          m.put(ResponseStateManager.VIEW_STATE_PARAM, 
+                new String[] {NULL_VIEW_STATE_PARAM_VALUE});
+        }
         requestMap.put(REQUEST_PARAMETERS, m);
       }
-    }
     else
     {
       // place the parameter map in the portlet request scope