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 2011/11/22 23:29:10 UTC
svn commit: r1205198 - in /myfaces/portlet-bridge/core/branches/trunk_2.0.x:
./ impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
Author: mfreedman
Date: Tue Nov 22 22:29:10 2011
New Revision: 1205198
URL: http://svn.apache.org/viewvc?rev=1205198&view=rev
Log:
PORTLETBRIDGE-219: Distinguish Faces Resource request.
PORTLETBRIDGE-221: Exclude request scope attributes.
Modified:
myfaces/portlet-bridge/core/branches/trunk_2.0.x/ (props changed)
myfaces/portlet-bridge/core/branches/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
myfaces/portlet-bridge/core/branches/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
Propchange: myfaces/portlet-bridge/core/branches/trunk_2.0.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov 22 22:29:10 2011
@@ -1 +1 @@
-/myfaces/portlet-bridge/core/branches/2.0.0-branch:1099967,1131166,1134753
+/myfaces/portlet-bridge/core/branches/2.0.0-branch:1099967,1131166,1134753,1160945
Modified: myfaces/portlet-bridge/core/branches/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java?rev=1205198&r1=1205197&r2=1205198&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java (original)
+++ myfaces/portlet-bridge/core/branches/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java Tue Nov 22 22:29:10 2011
@@ -1057,9 +1057,12 @@ public class BridgeImpl
// At a minimum we need to update the VIEW_STATE_PARAM being maintained
// However, if this is a resource request then we also update the full scope
- context.getExternalContext().getRequestMap().put(SCOPE_VIEW_KEY, getScopeViewKey(context.getExternalContext()));
- saveFacesMessageState(context);
- saveBridgeRequestScopeData(context, scopeId, preExistingAttributes, BridgeUtil.getPortletRequestPhase() == Bridge.PortletPhase.RESOURCE_PHASE);
+ if (BridgeUtil.getPortletRequestPhase() == Bridge.PortletPhase.RESOURCE_PHASE)
+ {
+ context.getExternalContext().getRequestMap().put(SCOPE_VIEW_KEY, getScopeViewKey(context.getExternalContext()));
+ saveFacesMessageState(context);
+ saveBridgeRequestScopeData(context, scopeId, preExistingAttributes, true);
+ }
updateViewInfo(context, scopeId);
}
@@ -1190,7 +1193,7 @@ public class BridgeImpl
private boolean isFacesResourceRequest(ResourceRequest request)
{
- return (request.getParameter(PortletExternalContextImpl.JSF_TARGET_VIEWID_RENDER_PARAMETER) != null ||
+ return (request.getParameter(PortletExternalContextImpl.JSF_TARGET_VIEWID_RESOURCE_PARAMETER) != null ||
request.getParameter(Bridge.FACES_VIEW_ID_PARAMETER) != null ||
request.getParameter(Bridge.FACES_VIEW_PATH_PARAMETER) != null);
}
@@ -1717,6 +1720,7 @@ public class BridgeImpl
return;
}
+
// now see if this scope is in the Map
Map<String, Object> scopeMap = requestScopeMap.get(scopeId);
if (scopeMap == null)
@@ -1724,6 +1728,16 @@ public class BridgeImpl
// Scope has been previously removed -- so no scope to update
return;
}
+
+ // I have made a change so that the scope is only updated in resource requests
+ // in render requests the old scope is retained -- however if this is a first render
+ // or a continuation of one then no scope has been written. In this case there is
+ // still an unwritable Collections.EMPTY_MAP in the scope as a placeholder. For this
+ // case we check for it here and replace with an empty writable one.
+ if (scopeMap.equals(Collections.EMPTY_MAP))
+ {
+ scopeMap = new HashMap<String, Object>(1);
+ }
// Now get the RequestParameters from the scope
@SuppressWarnings("unchecked")
@@ -1964,7 +1978,9 @@ public class BridgeImpl
// This call just gets us a new scopeId
String requestScopeId = createBridgeRequestScope(request);
- // This call ensures the new scopeId is in the ScopeMap
+ // This call ensures the new scopeId is in the ScopeMap but places an EMPTY_MAP
+ // palceholder in the scope which isn't writable -- the writable
+ // one shows up later when/if we write
clearBridgeRequestScopeData(requestScopeId);
// Now ensure the scopeId can be recovered in the next request
Modified: myfaces/portlet-bridge/core/branches/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java?rev=1205198&r1=1205197&r2=1205198&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java (original)
+++ myfaces/portlet-bridge/core/branches/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java Tue Nov 22 22:29:10 2011
@@ -105,6 +105,8 @@ public class PortletExternalContextImpl
// Render parameter to store the viewId
public static final String JSF_TARGET_VIEWID_RENDER_PARAMETER = "__jpfbJSFTARGET";
+ public static final String JSF_TARGET_VIEWID_RESOURCE_PARAMETER = "__jpfbJSFResTARGET";
+
public static final String NO_SCOPE = "org.apache.myfaces.portlet.faces.noScope";
public static final String SERVLET_INCLUDED_PATHINFO_ATTRIBUTE = "javax.servlet.include.path_info";
@@ -383,7 +385,7 @@ public class PortletExternalContextImpl
if (viewId != null)
{
- encodeFacesActionTarget(queryStr, viewId);
+ encodeFacesActionTarget(queryStr, viewId, (urlType != Bridge.PortletPhase.RESOURCE_PHASE) ? JSF_TARGET_VIEWID_RENDER_PARAMETER : JSF_TARGET_VIEWID_RESOURCE_PARAMETER);
}
else
{
@@ -897,7 +899,7 @@ public class PortletExternalContextImpl
{
// This is a Faces resource
// put the viewId in the QueryStr.
- queryStr.addParameter(JSF_TARGET_VIEWID_RENDER_PARAMETER, viewId);
+ queryStr.addParameter(JSF_TARGET_VIEWID_RESOURCE_PARAMETER, viewId);
queryStr.removeParameter(Bridge.PORTLET_MODE_PARAMETER);
queryStr.removeParameter(Bridge.PORTLET_WINDOWSTATE_PARAMETER);
}
@@ -1643,8 +1645,17 @@ public class PortletExternalContextImpl
if (viewId == null)
{
// Read the target from the request parameter
-
- viewId = mPortletRequest.getParameter(JSF_TARGET_VIEWID_RENDER_PARAMETER);
+
+ // We encode the viewId in a different parameter in the resource request
+ // As resource requests can't set render parameters (and hence we might get the old one back in case one not set)
+ if (getPortletPhase() != Bridge.PortletPhase.RESOURCE_PHASE)
+ {
+ viewId = mPortletRequest.getParameter(JSF_TARGET_VIEWID_RENDER_PARAMETER);
+ }
+ else
+ {
+ viewId = mPortletRequest.getParameter(JSF_TARGET_VIEWID_RESOURCE_PARAMETER);
+ }
if (viewId != null) debugLog("PortletExternalContextImpl.getViewId: found jsf target viewId = " + viewId);
@@ -2309,7 +2320,7 @@ public class PortletExternalContextImpl
return url;
}
- private void encodeFacesActionTarget(QueryString queryStr, String target)
+ private void encodeFacesActionTarget(QueryString queryStr, String target, String paramName)
{
// determine mode that we need to encode with this viewId
String mode = queryStr.getParameter(Bridge.PORTLET_MODE_PARAMETER);
@@ -2325,7 +2336,7 @@ public class PortletExternalContextImpl
}
// put the viewId in the QueryStr.
- queryStr.setParameter(JSF_TARGET_VIEWID_RENDER_PARAMETER,
+ queryStr.setParameter(paramName,
new StringBuffer(100).append(mode).append(':').append(target).toString());
}