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:16:31 UTC
svn commit: r964223 - in
/myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces:
application/ bridge/ context/
Author: mfreedman
Date: Wed Jul 14 22:16:31 2010
New Revision: 964223
URL: http://svn.apache.org/viewvc?rev=964223&view=rev
Log:
PORTLETBRIDGE-155: Bridge's event (lifecycle) processing doesn't recognize/handle redirect (properly)
PORTLETBRIDGE-154: ApplicationFactoryImpl should cache the Application instance it creates/returns
PORTLETBRIDGE-153: Bridge ExternalContext.redirect needs to throw IllegalStateException when render redirect to a nonFaces view
PORTLETBRIDGE-151: Bridge ViewHandler incompatible with Trinidad: if access as servlet restoreView fails to restore proper instance
Modified:
myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletApplicationFactoryImpl.java
myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java
myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
Modified: myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletApplicationFactoryImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletApplicationFactoryImpl.java?rev=964223&r1=964222&r2=964223&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletApplicationFactoryImpl.java (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletApplicationFactoryImpl.java Wed Jul 14 22:16:31 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_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java?rev=964223&r1=964222&r2=964223&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java Wed Jul 14 22:16:31 2010
@@ -94,24 +94,28 @@ 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 processing accoring 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("/#"))
+ {
+ 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.
}
}
@@ -148,24 +152,29 @@ public class PortletViewHandlerImpl exte
// 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.createView(facesContext, viewId);
+ }
+
+
+ // else its a portlet request so processing accoring 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("/#"))
+ {
+ 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.
}
}
Modified: myfaces/portlet-bridge/core/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/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java?rev=964223&r1=964222&r2=964223&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java Wed Jul 14 22:16:31 2010
@@ -567,6 +567,9 @@ public class BridgeImpl
// call the eventhandler to process
EventNavigationResult result = mEventHandler.handleEvent(context, request.getEvent());
+ // If redirected either during lifecycle or event handling merely return as new target is already encoded in response.
+ if (context.getResponseComplete()) return;
+
if (result != null)
{
context.getApplication().getNavigationHandler().handleNavigation(context, result.getFromAction(), result.getOutcome());
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=964223&r1=964222&r2=964223&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 Wed Jul 14 22:16:31 2010
@@ -618,14 +618,14 @@ public class PortletExternalContextImpl
private void redirectDuringEvent(String url)
throws IOException
{
- redirectFacesView(url);
+ redirectPortletView(url, false);
}
private void redirectDuringRender(String url)
throws IOException
{
// As this doesn't go back to the consumer -- we need to reencode the public render parameters so they are there
- redirectFacesView(encodePublicRenderParameters(url));
+ redirectPortletView(encodePublicRenderParameters(url), true);
}
private String encodePublicRenderParameters(String inUrl)
@@ -671,7 +671,7 @@ public class PortletExternalContextImpl
return outUrl.append("?").append(queryStr.toString()).toString();
}
- private void redirectFacesView(String url)
+ private void redirectPortletView(String url, boolean isRenderPhase)
throws IOException
{
// Distinguish between redirects to other Faces views in this app
@@ -684,19 +684,20 @@ public class PortletExternalContextImpl
QueryString params = (QueryString) getRequestMap().get(ENCODED_ACTION_URL_ATTRIBUTE_PREFIX.concat(url));
if (params != null)
{
- // Only can redirect to other Faces views in an event request
- if (params.getParameter(JSF_TARGET_VIEWID_RENDER_PARAMETER) != null)
+ // Only can redirect to other Faces views in an render request
+ if (isRenderPhase && params.getParameter(JSF_TARGET_VIEWID_RENDER_PARAMETER) == null)
{
- // Because we want to support translating a redirect that occurs
- // during a render as an in place navigation AND we can't reverse
- // engineer the URL from the actionURL, we stash the original URL on
- // a request attribute, keyed with the generated URL. If this generated
- // url is passed to redirect() we can get the original url back and
- // process based on it.
-
- getRequestMap().put(BridgeImpl.REDIRECT_VIEWPARAMS, params);
- FacesContext.getCurrentInstance().responseComplete();
- } // else do nothing as per spec
+ throw new IllegalStateException("Can't redirect during render to a NonFaces target: " + url);
+ }
+ // Because we want to support translating a redirect that occurs
+ // during a render as an in place navigation AND we can't reverse
+ // engineer the URL from the actionURL, we stash the original URL on
+ // a request attribute, keyed with the generated URL. If this generated
+ // url is passed to redirect() we can get the original url back and
+ // process based on it.
+
+ getRequestMap().put(BridgeImpl.REDIRECT_VIEWPARAMS, params);
+ FacesContext.getCurrentInstance().responseComplete();
}
else if ((url.startsWith("#") || isExternalURL(url) || isDirectLink(url)))
{
@@ -708,7 +709,7 @@ public class PortletExternalContextImpl
// is it an unencoded Faces URL -- process it.
// recurse on redirect after calling encodeActionURL which will
// cause the attribute to be set.
- redirectFacesView(encodeActionURL(url));
+ redirectPortletView(encodeActionURL(url), isRenderPhase);
}
// else nothing to do