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/06/24 00:45:25 UTC
svn commit: r787864 - in /myfaces/portlet-bridge/core/trunk_2.0.x:
api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java
impl/src/main/java/org/apache/myfaces/portlet/faces/el/PortletELResolver.java
Author: mfreedman
Date: Tue Jun 23 22:45:25 2009
New Revision: 787864
URL: http://svn.apache.org/viewvc?rev=787864&view=rev
Log:
PORTLETBRIDGE-83: JSP sessionScope ELResolution fails for ManagedBeans
PORTLETBRIDGE-82: Add support for GenericFacesPortlet spec changes
Modified:
myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.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/GenericFacesPortlet.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java?rev=787864&r1=787863&r2=787864&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java Tue Jun 23 22:45:25 2009
@@ -24,6 +24,8 @@
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletConfig;
import javax.portlet.PortletContext;
@@ -112,6 +114,12 @@
*/
public static final String DEFAULT_CHARACTERSET_ENCODING =
Bridge.BRIDGE_PACKAGE_PREFIX + "defaultCharacterSetEncoding";
+
+ /** Portlet init parameter containing the setting for whether the <code>GenericFacesPortlet</code>
+ * overrides event processing by dispatching all events to the bridge or delegates
+ * all event processing to the <code>GenericPortlet</code>. Default is <code>true</code>.
+ */
+ public static final String BRIDGE_AUTO_DISPATCH_EVENTS = Bridge.BRIDGE_PACKAGE_PREFIX + "autoDispatchEvents";
/** Location of the services descriptor file in a brige installation that defines
* the class name of the bridge implementation.
@@ -501,6 +509,63 @@
return mDefaultViewIdMap;
}
+
+ /**
+ * Returns the value of the portlet initialization parameter
+ * <code>javax.portlet.faces.autoDispatchEvents</code> if non-null or
+ * <code>true</code>, otherwise.
+ *
+ * @return boolean indicating whether to auto-dispatch all events to the bridge
+ * or not.
+ */
+ public boolean isAutoDispatchEvents()
+ {
+ String configParam =
+ getPortletConfig().getPortletContext().getInitParameter(BRIDGE_AUTO_DISPATCH_EVENTS);
+
+ if (configParam != null)
+ {
+ return Boolean.parseBoolean(configParam);
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ /**
+ * Returns an initialized bridge instance adequately prepared so the caller can
+ * call doFacesRequest directly without further initialization.
+ *
+ * @return instance of the bridge.
+ * @throws PortletException exception acquiring or initializting the bridge.
+ */
+ public Bridge getFacesBridge(PortletRequest request,
+ PortletResponse response) throws PortletException
+ {
+ initBridgeRequest(request, response);
+ return mFacesBridge;
+ }
+
+ public void processEvent(EventRequest request, EventResponse response)
+ throws PortletException, java.io.IOException
+ {
+ if (isAutoDispatchEvents())
+ {
+ try
+ {
+ getFacesBridge(request, response).doFacesRequest(request, response);
+ } catch (BridgeException e)
+ {
+ throw new PortletException("doBridgeDispatch failed: error from Bridge in executing the request",
+ e);
+ }
+ }
+ else
+ {
+ super.processEvent(request, response);
+ }
+ }
private boolean isNonFacesRequest(PortletRequest request, PortletResponse response)
{
@@ -575,13 +640,9 @@
private void doBridgeDispatch(RenderRequest request,
RenderResponse response) throws PortletException
{
- // initial Bridge if not already active
- initBridgeRequest(request, response);
-
- // Set the response ContentType/CharacterSet
try
{
- mFacesBridge.doFacesRequest(request, response);
+ getFacesBridge(request, response).doFacesRequest(request, response);
} catch (BridgeException e)
{
throw new PortletException("doBridgeDispatch failed: error from Bridge in executing the request",
@@ -593,12 +654,9 @@
private void doBridgeDispatch(ActionRequest request,
ActionResponse response) throws PortletException
{
- // initial Bridge if not already active
- initBridgeRequest(request, response);
-
try
{
- mFacesBridge.doFacesRequest(request, response);
+ getFacesBridge(request, response).doFacesRequest(request, response);
} catch (BridgeException e)
{
throw new PortletException("doBridgeDispatch failed: error from Bridge in executing the request",
@@ -610,13 +668,9 @@
private void doBridgeDispatch(ResourceRequest request,
ResourceResponse response) throws PortletException
{
- // initial Bridge if not already active
- initBridgeRequest(request, response);;
-
-
try
{
- mFacesBridge.doFacesRequest(request, response);
+ getFacesBridge(request, response).doFacesRequest(request, response);
} catch (BridgeException e)
{
throw new PortletException("doBridgeDispatch failed: error from Bridge in executing the request",
@@ -632,7 +686,7 @@
// Now do any per request initialization
- // I nthis case look to see if the request is encoded (usually
+ // In this case look to see if the request is encoded (usually
// from a NonFaces view response) with the specific Faces
// view to execute.
String view = request.getParameter(Bridge.FACES_VIEW_ID_PARAMETER);
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=787864&r1=787863&r2=787864&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 Jun 23 22:45:25 2009
@@ -277,7 +277,24 @@
}
} catch (IllegalArgumentException e)
{
- return null;
+ // Faces defers to the implicit object resolver when evaluating
+ // in a JSP context. Alas, this means that Faces doesn't resolve
+ // session scoped ManagedBeans in a JSP context if the managed bean
+ // is already created rather it defers to the JSP Implicit resolver
+ // which accesses the http session not the protlet session. I.e.
+ // though the managed bean resolver sees that the session scoped bean
+ // exists it can't be retrieved because its in the portlet session
+ // not the http session.
+ // So its up to us to see if the bean is in the session
+ if (extCtx.getSessionMap().containsKey(property))
+ {
+ context.setPropertyResolved(true);
+ return extCtx.getSessionMap().get(property);
+ }
+ else
+ {
+ return null;
+ }
}
} else
{