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/01/19 22:46:22 UTC
svn commit: r900973 - in /myfaces/portlet-bridge/core/trunk_2.0.x:
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/
Author: mfreedman
Date: Tue Jan 19 21:46:22 2010
New Revision: 900973
URL: http://svn.apache.org/viewvc?rev=900973&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_2.0.x/api/src/main/java/javax/portlet/faces/Bridge.java
myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java
myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/el/PortletELResolver.java
Modified: myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/Bridge.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/Bridge.java?rev=900973&r1=900972&r2=900973&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/Bridge.java (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/Bridge.java Tue Jan 19 21:46:22 2010
@@ -337,6 +337,15 @@
* BRIDGE_PACKAGE_PREFIX + context.getPortletName() + bridgeEventHandler
*/
public static final String BRIDGE_PUBLIC_RENDER_PARAMETER_HANDLER = "bridgePublicRenderParameterHandler";
+
+ /** 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
Modified: myfaces/portlet-bridge/core/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/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java?rev=900973&r1=900972&r2=900973&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java Tue Jan 19 21:46:22 2010
@@ -264,11 +264,11 @@
public String encodeActionURL(String url)
{
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
@@ -276,7 +276,6 @@
if (isPortletURL(url))
{
isPortletURL = true;
- nonFacesAction = true;
//URL is of the form scheme:urlType?queryString
// remove the scheme
path = url.substring(url.indexOf(":")+ 1);
@@ -307,6 +306,27 @@
+ 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))
{
@@ -355,7 +375,6 @@
else
{
// URL points at non-Faces action
- nonFacesAction = true;
encodeNonFacesActionTarget(queryStr, path);
}
}
@@ -372,24 +391,17 @@
ResourceURL resourceURL = null;
BaseURL baseURL = 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)
- {
- baseURL = actionURL = mimeResponse.createActionURL();
- }
- else if (isPortletURL && urlType == Bridge.PortletPhase.RESOURCE_PHASE)
- {
- baseURL = resourceURL = mimeResponse.createResourceURL();
- }
- else
- {
- baseURL = actionURL = mimeResponse.createRenderURL();
- }
- }
+ baseURL = actionURL = mimeResponse.createActionURL();
+ }
+ else if (urlType == Bridge.PortletPhase.RESOURCE_PHASE)
+ {
+ baseURL = resourceURL = mimeResponse.createResourceURL();
+ }
else
{
- baseURL = actionURL = mimeResponse.createActionURL();
+ baseURL = actionURL = mimeResponse.createRenderURL();
}
// Add parameters so they don't get lost
@@ -435,6 +447,13 @@
baseURL.setParameter(param, queryStr.getParameter(param));
}
}
+
+ // Carry forward render parameters if this is a portlet:url that references the current view
+ if (isPortletURLSelfReference)
+ {
+ carryForwardRenderParameters(baseURL, mPortletRequest.getPrivateParameterMap(), queryStr);
+ carryForwardRenderParameters(baseURL, mPortletRequest.getPublicParameterMap(), queryStr);
+ }
// Some portlet containers implementing wsrp choose to separate the
// consumer rewrite string that represents this URL using & as the
@@ -505,6 +524,21 @@
return url;
}
+
+ private void carryForwardRenderParameters(BaseURL url, Map<String, String[]> m, QueryString queryStr)
+ {
+ 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)
+ {
+ url.setParameter(entry.getKey(), entry.getValue());
+ }
+ }
+ }
@Override
public void redirect(String url)
Modified: myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java?rev=900973&r1=900972&r2=900973&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java Tue Jan 19 21:46:22 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_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/el/PortletELResolver.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/el/PortletELResolver.java?rev=900973&r1=900972&r2=900973&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/el/PortletELResolver.java (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/el/PortletELResolver.java Tue Jan 19 21:46:22 2010
@@ -91,7 +91,13 @@
@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)
@@ -99,12 +105,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.
@@ -372,17 +372,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