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 2008/12/05 23:11:05 UTC
svn commit: r723896 - in /myfaces/portlet-bridge/core/trunk:
api/src/main/java/javax/portlet/faces/ examples/demo/src/main/webapp/WEB-INF/
impl/src/main/java/org/apache/myfaces/portlet/faces/application/
impl/src/main/java/org/apache/myfaces/portlet/fa...
Author: mfreedman
Date: Fri Dec 5 14:11:05 2008
New Revision: 723896
URL: http://svn.apache.org/viewvc?rev=723896&view=rev
Log:
Fixes PORTLETBRIDGE-50, PORTLETBRIDGE-47, PORTLETBRIDGE-46, PORTLETBRIDGE-45
This checkin brings the Portlet 1.0 Bridge up to date with the Proposed Final Draft of the specification.
Modified:
myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/Bridge.java
myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java
myfaces/portlet-bridge/core/trunk/examples/demo/src/main/webapp/WEB-INF/portlet.xml
myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java
myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/FacesContextFactoryImpl.java
myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java
Modified: myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/Bridge.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/Bridge.java?rev=723896&r1=723895&r2=723896&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/Bridge.java (original)
+++ myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/Bridge.java Fri Dec 5 14:11:05 2008
@@ -48,8 +48,7 @@
{
// Base Bridge attribute/context parameter prefix
- public static final String BRIDGE_PACKAGE_PREFIX =
- "javax.portlet.faces.";
+ public static final String BRIDGE_PACKAGE_PREFIX = "javax.portlet.faces.";
// Following are the names of context init parameters that control
// Bridge behavior. These are specified in the web.xml
@@ -58,7 +57,8 @@
* Context initialization parameter that specifies the maximum number of bridge
* request scopes to preserved across all uses within this application.
*/
- public static final String MAX_MANAGED_REQUEST_SCOPES = BRIDGE_PACKAGE_PREFIX + "MAX_MANAGED_REQUEST_SCOPES";
+ public static final String MAX_MANAGED_REQUEST_SCOPES =
+ BRIDGE_PACKAGE_PREFIX + "MAX_MANAGED_REQUEST_SCOPES";
/**
* Context initialization parameter that defines the policy the bridge uses for
@@ -80,12 +80,13 @@
* detects and supports. For example the bridge RI will detect and run
* properly in either the Faces RI or MyFaces environments without this being set.
*/
- public static final String SAVESTATE_FIELD_MARKER = BRIDGE_PACKAGE_PREFIX + "SAVESTATE_FIELD_MARKER";
+ public static final String SAVESTATE_FIELD_MARKER =
+ BRIDGE_PACKAGE_PREFIX + "SAVESTATE_FIELD_MARKER";
// Following are the names of context init attributes set by the portlet to control
// Bridge behavior. For the GenericFacesPortlet, the values for these come from
// portlet initialization parameters in the portlet.xml
-
+
/** A PortletContext attribute that a portlet can set prior
* to calling the bridge's init() method to configure the bridge to preserve
* action parameters received by this portlet along with bridge's request scope so
@@ -125,10 +126,10 @@
* BRIDGE_PACKAGE_PREFIX + context.getPortletName() + DEFAULT_VIEWID_MAP
*/
public static final String DEFAULT_VIEWID_MAP = "defaultViewIdMap";
-
+
// The following are request attributes a portlet can set to control the request
// processing of the bridge.
-
+
/** PortletRequest attribute that a portlet may set prior
* to calling the bridge's doFacesRequest() method. The value of this
* attribute is a <code>String</code> representing the Faces viewId the
@@ -140,7 +141,7 @@
* precedence to VIEW_ID.
*/
public static final String VIEW_ID = BRIDGE_PACKAGE_PREFIX + "viewId";
-
+
/** PortletRequest attribute that a portlet may set prior
* to calling the bridge's doFacesRequest() method. The value of this
* attribute is a <code>String</code> containing a <code>ContextPath</code>
@@ -226,7 +227,8 @@
* rendering the view components. In conjunction with the filter this enables
* preserving rendering order of native JSP rendering and Faces rendering in a jsp.
*/
- public static final String RENDER_CONTENT_AFTER_VIEW = BRIDGE_PACKAGE_PREFIX + "RenderContentAfterView";
+ public static final String RENDER_CONTENT_AFTER_VIEW =
+ BRIDGE_PACKAGE_PREFIX + "RenderContentAfterView";
/** A PortletRequest attribute set by an include filter in recognition of the
* RenderContentAfterView bridge attribute. Its value is either char[] or byte[]
@@ -259,8 +261,9 @@
* view has been rendered using a <code>NamingContainer</code> that ensures all
* generated ids are namespaced using the consumer provided unique portlet id.
*/
- public static final String PORTLET_NAMESPACED_RESPONSE_PROPERTY = "X-JAVAX-PORTLET-NAMESPACED-RESPONSE";
-
+ public static final String PORTLET_NAMESPACED_RESPONSE_PROPERTY =
+ "X-JAVAX-PORTLET-NAMESPACED-RESPONSE";
+
/** Name of the render parameter set by the bridge when it encodes a navigation
* link to a nonFaces target. Though the bridge recognizes nonFaces targets when
* it encodes a navigational link, it does not handle the subsequent request.
@@ -273,7 +276,7 @@
* path instead of calling the bridge to execute the request.
*/
public static final String NONFACES_TARGET_PATH_PARAMETER = "_jsfBridgeNonFacesView";
-
+
/** Name of a request parameter (generally) encoded in a link from a nonFaces
* view response. It acts as a marker to the portlet that the nonFaces view
* intends to navigate to the Faces view expressed in the value of this parameter.
@@ -285,7 +288,7 @@
* to handle the request.
*/
public static final String FACES_VIEW_ID_PARAMETER = "_jsfBridgeViewId";
-
+
/** Name of a request parameter (generally) encoded in a link from a nonFaces
* view response. It acts as a marker to the portlet that the nonFaces view
* intends to navigate to the Faces view expressed in the value of this parameter.
@@ -390,9 +393,9 @@
* all other internal exceptions are converted to a BridgeException.
*/
public void doFacesRequest(ActionRequest request,
- ActionResponse response)
- throws BridgeDefaultViewNotSpecifiedException,
- BridgeUninitializedException, BridgeException;
+ ActionResponse response) throws BridgeDefaultViewNotSpecifiedException,
+ BridgeUninitializedException,
+ BridgeException;
/**
* Called by the portlet when it wants the bridge to process a render request.
@@ -410,9 +413,9 @@
* all other internal exceptions are converted to a BridgeException.
*/
public void doFacesRequest(RenderRequest request,
- RenderResponse response)
- throws BridgeDefaultViewNotSpecifiedException,
- BridgeUninitializedException, BridgeException;
+ RenderResponse response) throws BridgeDefaultViewNotSpecifiedException,
+ BridgeUninitializedException,
+ BridgeException;
/**
* Called by the portlet to take the bridge out of service. Once out of service, the bridge must
Modified: myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java?rev=723896&r1=723895&r2=723896&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java (original)
+++ myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java Fri Dec 5 14:11:05 2008
@@ -69,7 +69,7 @@
* basis the default character set encoding the bridge should set for all render requests it
* processes</li>
* </ul>
- * The <code>GenericFacesPortlet</code> recognizes the following application
+ * The <code>GenericFacesPortlet</code> recognizes the following application
* (<code>PortletContext</code>) initialization parameters:
* <ul>
* <li><code>javax.portlet.faces.BridgeImplClass</code>: specifies the <code>Bridge</code>implementation
@@ -86,40 +86,40 @@
* by this application. Typically not used unless more then 1 bridge is configured
* in an environment as its more usual to rely on the self detection.
*/
- public static final String BRIDGE_CLASS = Bridge.BRIDGE_PACKAGE_PREFIX
- + "BridgeImplClass";
+ public static final String BRIDGE_CLASS = Bridge.BRIDGE_PACKAGE_PREFIX + "BridgeImplClass";
/** Portlet init parameter that defines the default ViewId that should be used
* when the request doesn't otherwise convery the target. There must be one
* initialization parameter for each supported mode. Each parameter is named
* DEFAULT_VIEWID.<i>mode</i>, where <i>mode</i> is the name of the corresponding
* <code>PortletMode</code>
- */
- public static final String DEFAULT_VIEWID = Bridge.BRIDGE_PACKAGE_PREFIX
- + "defaultViewId";
+ */
+ public static final String DEFAULT_VIEWID = Bridge.BRIDGE_PACKAGE_PREFIX + "defaultViewId";
/** Portlet init parameter that defines the render response ContentType the bridge
* sets prior to rendering. If not set the bridge uses the request's preferred
* content type.
*/
- public static final String DEFAULT_CONTENT_TYPE = Bridge.BRIDGE_PACKAGE_PREFIX
- + "defaultContentType";
+ public static final String DEFAULT_CONTENT_TYPE =
+ Bridge.BRIDGE_PACKAGE_PREFIX + "defaultContentType";
+
/** Portlet init parameter that defines the render response CharacterSetEncoding the bridge
* sets prior to rendering. Typcially only set when the jsp outputs an encoding other
* then the portlet container's and the portlet container supports response encoding
* transformation.
- */
- public static final String DEFAULT_CHARACTERSET_ENCODING = Bridge.BRIDGE_PACKAGE_PREFIX
- + "defaultCharacterSetEncoding";
-
+ */
+ public static final String DEFAULT_CHARACTERSET_ENCODING =
+ Bridge.BRIDGE_PACKAGE_PREFIX + "defaultCharacterSetEncoding";
+
/** Location of the services descriptor file in a brige installation that defines
* the class name of the bridge implementation.
*/
- public static final String BRIDGE_SERVICE_CLASSPATH = "META-INF/services/javax.portlet.faces.Bridge";
+ public static final String BRIDGE_SERVICE_CLASSPATH =
+ "META-INF/services/javax.portlet.faces.Bridge";
- private Class<? extends Bridge> mFacesBridgeClass = null;
- private Bridge mFacesBridge = null;
- private HashMap<String,String> mDefaultViewIdMap = null;
+ private Class<? extends Bridge> mFacesBridgeClass = null;
+ private Bridge mFacesBridge = null;
+ private HashMap<String, String> mDefaultViewIdMap = null;
/**
* Initialize generic faces portlet from portlet.xml
@@ -139,9 +139,8 @@
try
{
ClassLoader loader = Thread.currentThread().getContextClassLoader();
- mFacesBridgeClass = (Class<? extends Bridge>)loader.loadClass(bridgeClassName);
- }
- catch (ClassNotFoundException cnfe)
+ mFacesBridgeClass = (Class<? extends Bridge>) loader.loadClass(bridgeClassName);
+ } catch (ClassNotFoundException cnfe)
{
// Do nothing and fall through to null check
}
@@ -149,31 +148,25 @@
if (mFacesBridgeClass == null)
{
- throw new PortletException("Configuration Error: Initial Parameter '" + BRIDGE_CLASS
- + "' is not defined for portlet: " + getPortletName());
+ throw new PortletException("Configuration Error: Initial Parameter '" + BRIDGE_CLASS +
+ "' is not defined for portlet: " + getPortletName());
}
-
+
// Get the other bridge configuration parameters and set as context attributes
List<String> excludedAttrs = getExcludedRequestAttributes();
if (excludedAttrs != null)
{
- getPortletContext().setAttribute(
- Bridge.BRIDGE_PACKAGE_PREFIX + getPortletName() + "."
- + Bridge.EXCLUDED_REQUEST_ATTRIBUTES,
- excludedAttrs);
- }
-
- Boolean preserveActionParams = getPreserveActionParameters();
- getPortletContext().setAttribute(
- Bridge.BRIDGE_PACKAGE_PREFIX + getPortletName() + "."
- + Bridge.PRESERVE_ACTION_PARAMS,
- preserveActionParams);
+ getPortletContext().setAttribute(Bridge.BRIDGE_PACKAGE_PREFIX + getPortletName() + "." +
+ Bridge.EXCLUDED_REQUEST_ATTRIBUTES, excludedAttrs);
+ }
+
+ Boolean preserveActionParams = new Boolean(isPreserveActionParameters());
+ getPortletContext().setAttribute(Bridge.BRIDGE_PACKAGE_PREFIX + getPortletName() + "." +
+ Bridge.PRESERVE_ACTION_PARAMS, preserveActionParams);
Map defaultViewIdMap = getDefaultViewIdMap();
- getPortletContext().setAttribute(
- Bridge.BRIDGE_PACKAGE_PREFIX + getPortletName() + "."
- + Bridge.DEFAULT_VIEWID_MAP,
- defaultViewIdMap);
+ getPortletContext().setAttribute(Bridge.BRIDGE_PACKAGE_PREFIX + getPortletName() + "." +
+ Bridge.DEFAULT_VIEWID_MAP, defaultViewIdMap);
// Don't instanciate/initialize the bridge yet. Do it on first use
}
@@ -198,16 +191,15 @@
* override. Otherwise handle mode here if there is a defaultViewId mapping for it.
*/
@Override
- public void doDispatch(RenderRequest request, RenderResponse response) throws PortletException,
- IOException
+ public void doDispatch(RenderRequest request, RenderResponse response) throws PortletException,
+ IOException
{
// Defer to helper methods for standard modes so subclasses can override
PortletMode mode = request.getPortletMode();
if (mode == PortletMode.EDIT || mode == PortletMode.HELP || mode == PortletMode.VIEW)
{
super.doDispatch(request, response);
- }
- else
+ } else
{
// Bridge didn't process this one -- so forge ahead
if (!doRenderDispatchInternal(request, response))
@@ -218,33 +210,29 @@
}
@Override
- protected void doEdit(RenderRequest request, RenderResponse response) throws PortletException,
- java.io.IOException
+ protected void doEdit(RenderRequest request, RenderResponse response) throws PortletException,
+ java.io.IOException
{
doRenderDispatchInternal(request, response);
-
}
@Override
- protected void doHelp(RenderRequest request, RenderResponse response) throws PortletException,
- java.io.IOException
+ protected void doHelp(RenderRequest request, RenderResponse response) throws PortletException,
+ java.io.IOException
{
doRenderDispatchInternal(request, response);
-
}
@Override
- protected void doView(RenderRequest request, RenderResponse response) throws PortletException,
- java.io.IOException
+ protected void doView(RenderRequest request, RenderResponse response) throws PortletException,
+ java.io.IOException
{
doRenderDispatchInternal(request, response);
-
}
@Override
- public void processAction(ActionRequest request, ActionResponse response)
- throws PortletException,
- IOException
+ public void processAction(ActionRequest request,
+ ActionResponse response) throws PortletException, IOException
{
doActionDispatchInternal(request, response);
}
@@ -259,15 +247,13 @@
*/
public List<String> getExcludedRequestAttributes()
{
- String excludedAttrs = getPortletConfig()
- .getInitParameter(
- Bridge.BRIDGE_PACKAGE_PREFIX
- + Bridge.EXCLUDED_REQUEST_ATTRIBUTES);
- if (excludedAttrs == null)
+ String excludedAttrs =
+ getPortletConfig().getInitParameter(Bridge.BRIDGE_PACKAGE_PREFIX + Bridge.EXCLUDED_REQUEST_ATTRIBUTES);
+ if (excludedAttrs == null)
{
return null;
}
-
+
String[] attrArray = excludedAttrs.split(",");
// process comma delimited String into a List
ArrayList<String> list = new ArrayList(attrArray.length);
@@ -287,19 +273,17 @@
* @return a boolean indicating whether or not the bridge should preserve all the
* action parameters in the subsequent renders that occur in the same scope.
*/
- public Boolean getPreserveActionParameters()
+ public boolean isPreserveActionParameters()
{
- String preserveActionParams = getPortletConfig()
- .getInitParameter(
- Bridge.BRIDGE_PACKAGE_PREFIX
- + Bridge.PRESERVE_ACTION_PARAMS);
+ String preserveActionParams =
+ getPortletConfig().getInitParameter(Bridge.BRIDGE_PACKAGE_PREFIX +
+ Bridge.PRESERVE_ACTION_PARAMS);
if (preserveActionParams == null)
{
- return Boolean.FALSE;
- }
- else
+ return false;
+ } else
{
- return Boolean.valueOf(preserveActionParams);
+ return Boolean.parseBoolean(preserveActionParams);
}
}
@@ -319,56 +303,52 @@
if (bridgeClassName == null)
{
- bridgeClassName = getFromServicesPath(getPortletConfig().getPortletContext(),
- BRIDGE_SERVICE_CLASSPATH);
+ bridgeClassName =
+ getFromServicesPath(getPortletConfig().getPortletContext(), BRIDGE_SERVICE_CLASSPATH);
}
return bridgeClassName;
}
-
-/**
- * Returns the default content type for this portlet request. Subclasses override to
- * alter the default behavior. Default implementation returns value of the portlet context init
- * parameter: javax.portlet.faces.DefaultContentType. If it doesn't exist the portlet
- * request's preferred response content type is returned.
- *
- * Note: This support is specific to the Portlet 1.0 Bridge. Its value is
- * likely to be ignored by the Portlet 2.0 Bridge or later.
- *
- * @return the content type that should be used for this response.
- */
+
+ /**
+ * Returns the default content type for this portlet request. Subclasses override to
+ * alter the default behavior. Default implementation returns value of the portlet context init
+ * parameter: javax.portlet.faces.DefaultContentType. If it doesn't exist the portlet
+ * request's preferred response content type is returned.
+ *
+ * Note: This support is specific to the Portlet 1.0 Bridge. Its value is
+ * likely to be ignored by the Portlet 2.0 Bridge or later.
+ *
+ * @return the content type that should be used for this response.
+ */
public String getResponseContentType(PortletRequest request)
{
- String contentType =
- getPortletConfig().getPortletContext()
- .getInitParameter(DEFAULT_CONTENT_TYPE);
-
+ String contentType =
+ getPortletConfig().getPortletContext().getInitParameter(DEFAULT_CONTENT_TYPE);
+
if (contentType == null)
{
- contentType = request.getResponseContentType();
+ contentType = request.getResponseContentType();
}
return contentType;
}
/**
- * Returns the character set encoding used for this portlet response. Subclasses override to
- * alter the default behavior. Default implementation returns value of the portlet context init
- * parameter: javax.portlet.faces.DefaultCharacterSetEncoding. If it doesn't exist null
- * is returned.
- *
- * Note: This support is specific to the Portlet 1.0 Bridge. Its value is
- * likely to be ignored by the Portlet 2.0 Bridge or later.
- *
- * @return the content type that should be used for this response.
- */
+ * Returns the character set encoding used for this portlet response. Subclasses override to
+ * alter the default behavior. Default implementation returns value of the portlet context init
+ * parameter: javax.portlet.faces.DefaultCharacterSetEncoding. If it doesn't exist null
+ * is returned.
+ *
+ * Note: This support is specific to the Portlet 1.0 Bridge. Its value is
+ * likely to be ignored by the Portlet 2.0 Bridge or later.
+ *
+ * @return the content type that should be used for this response.
+ */
public String getResponseCharacterSetEncoding(PortletRequest request)
{
- return
- getPortletConfig().getPortletContext()
- .getInitParameter(DEFAULT_CHARACTERSET_ENCODING);
+ return getPortletConfig().getPortletContext().getInitParameter(DEFAULT_CHARACTERSET_ENCODING);
}
-
/**
* Returns the defaultViewIdMap the bridge should use when its unable to resolve to a specific
* target in the incoming request. There is one entry per support <code>PortletMode
@@ -379,13 +359,13 @@
*/
public Map getDefaultViewIdMap()
{
- if (mDefaultViewIdMap == null)
+ if (mDefaultViewIdMap == null)
{
mDefaultViewIdMap = new HashMap<String, String>();
// loop through all portlet initialization parameters looking for those in the
// correct form
PortletConfig config = getPortletConfig();
-
+
Enumeration<String> e = config.getInitParameterNames();
int len = DEFAULT_VIEWID.length();
while (e.hasMoreElements())
@@ -395,15 +375,15 @@
{
String viewId = config.getInitParameter(s);
// extract the mode
- s = s.substring(len+1);
+ s = s.substring(len + 1);
mDefaultViewIdMap.put(s, viewId);
}
}
}
-
+
return mDefaultViewIdMap;
}
-
+
private boolean isNonFacesRequest(PortletRequest request, PortletResponse response)
{
// Non Faces request is identified by either the presence of the _jsfBridgeNonFacesView
@@ -413,34 +393,34 @@
{
return true;
}
-
+
String modeDefaultViewId = mDefaultViewIdMap.get(request.getPortletMode().toString());
return modeDefaultViewId == null;
}
-
- private void doActionDispatchInternal(ActionRequest request, ActionResponse response)
- throws PortletException, IOException
+
+ private void doActionDispatchInternal(ActionRequest request,
+ ActionResponse response) throws PortletException,
+ IOException
{
// First determine whether this is a Faces or nonFaces request
if (isNonFacesRequest(request, response))
{
throw new PortletException("GenericFacesPortlet: Action request is not for a Faces target. Such nonFaces requests must be handled by a subclass.");
- }
- else
+ } else
{
doBridgeDispatch(request, response);
}
}
- private boolean doRenderDispatchInternal(RenderRequest request, RenderResponse response)
- throws PortletException, IOException
+ private boolean doRenderDispatchInternal(RenderRequest request,
+ RenderResponse response) throws PortletException,
+ IOException
{
// First determine whether this is a Faces or nonFaces request
if (isNonFacesRequest(request, response))
{
return doNonFacesDispatch(request, response);
- }
- else
+ } else
{
WindowState state = request.getWindowState();
if (!state.equals(WindowState.MINIMIZED))
@@ -450,9 +430,9 @@
return true;
}
}
-
- private boolean doNonFacesDispatch(RenderRequest request, RenderResponse response)
- throws PortletException
+
+ private boolean doNonFacesDispatch(RenderRequest request,
+ RenderResponse response) throws PortletException
{
// Can only dispatch if the path is encoded in the request parameter
String targetPath = request.getParameter(Bridge.NONFACES_TARGET_PATH_PARAMETER);
@@ -461,7 +441,7 @@
// Didn't handle this request
return false;
}
-
+
// merely dispatch this to the nonJSF target
// but because this is portlet 1.0 we have to ensure the content type is set.
// Ensure the ContentType is set before rendering
@@ -469,44 +449,41 @@
{
response.setContentType(request.getResponseContentType());
}
- try {
- PortletRequestDispatcher dispatcher = this.getPortletContext().getRequestDispatcher(targetPath);
+ try
+ {
+ PortletRequestDispatcher dispatcher =
+ this.getPortletContext().getRequestDispatcher(targetPath);
dispatcher.include(request, response);
return true;
- }
- catch (Exception e)
+ } catch (Exception e)
{
throw new PortletException("Unable to dispatch to: " + targetPath, e);
}
}
- private void doBridgeDispatch(RenderRequest request, RenderResponse response)
- throws PortletException
+ private void doBridgeDispatch(RenderRequest request,
+ RenderResponse response) throws PortletException
{
// initial Bridge if not already active
initBridgeRequest(request, response);
-
+
// Set the response ContentType/CharacterSet
- setResponseContentType(
- response,
- getResponseContentType(request),
- getResponseCharacterSetEncoding(request));
-
+ setResponseContentType(response, getResponseContentType(request),
+ getResponseCharacterSetEncoding(request));
+
try
{
mFacesBridge.doFacesRequest(request, response);
- }
- catch (BridgeException e)
+ } catch (BridgeException e)
{
- throw new PortletException(
- "doBridgeDispatch failed: error from Bridge in executing the request",
+ throw new PortletException("doBridgeDispatch failed: error from Bridge in executing the request",
e);
}
}
- private void doBridgeDispatch(ActionRequest request, ActionResponse response)
- throws PortletException
+ private void doBridgeDispatch(ActionRequest request,
+ ActionResponse response) throws PortletException
{
// initial Bridge if not already active
initBridgeRequest(request, response);
@@ -514,22 +491,20 @@
try
{
mFacesBridge.doFacesRequest(request, response);
- }
- catch (BridgeException e)
+ } catch (BridgeException e)
{
- throw new PortletException(
- "doBridgeDispatch failed: error from Bridge in executing the request",
+ throw new PortletException("doBridgeDispatch failed: error from Bridge in executing the request",
e);
}
}
-
- private void initBridgeRequest(PortletRequest request, PortletResponse response)
- throws PortletException
+
+ private void initBridgeRequest(PortletRequest request,
+ PortletResponse response) throws PortletException
{
initBridge();
-
-
+
+
// Now do any per request initialization
// I nthis case look to see if the request is encoded (usually
// from a NonFaces view response) with the specific Faces
@@ -538,8 +513,7 @@
if (view != null)
{
request.setAttribute(Bridge.VIEW_ID, view);
- }
- else
+ } else
{
view = request.getParameter(Bridge.FACES_VIEW_PATH_PARAMETER);
if (view != null)
@@ -558,23 +532,20 @@
{
mFacesBridge = mFacesBridgeClass.newInstance();
mFacesBridge.init(getPortletConfig());
- }
- catch (Exception e)
+ } catch (Exception e)
{
throw new PortletException("doBridgeDisptach: error instantiating the bridge class", e);
}
}
}
- private void setResponseContentType(
- RenderResponse response,
- String contentType,
- String charSetEncoding)
+ private void setResponseContentType(RenderResponse response, String contentType,
+ String charSetEncoding)
{
if (contentType == null)
{
return;
-
+
}
if (charSetEncoding != null)
{
@@ -582,8 +553,7 @@
buf.append(";");
buf.append(charSetEncoding);
response.setContentType(buf.toString());
- }
- else
+ } else
{
response.setContentType(contentType);
}
@@ -611,8 +581,7 @@
try
{
reader = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
- }
- catch (UnsupportedEncodingException e)
+ } catch (UnsupportedEncodingException e)
{
reader = new BufferedReader(new InputStreamReader(stream));
}
@@ -625,14 +594,11 @@
reader = null;
stream = null;
}
- }
- catch (IOException e)
+ } catch (IOException e)
{
- }
- catch (SecurityException e)
+ } catch (SecurityException e)
{
- }
- finally
+ } finally
{
if (reader != null)
{
@@ -640,8 +606,7 @@
{
reader.close();
stream = null;
- }
- catch (Throwable t)
+ } catch (Throwable t)
{
;
}
@@ -652,8 +617,7 @@
try
{
stream.close();
- }
- catch (Throwable t)
+ } catch (Throwable t)
{
;
}
Modified: myfaces/portlet-bridge/core/trunk/examples/demo/src/main/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk/examples/demo/src/main/webapp/WEB-INF/portlet.xml?rev=723896&r1=723895&r2=723896&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk/examples/demo/src/main/webapp/WEB-INF/portlet.xml (original)
+++ myfaces/portlet-bridge/core/trunk/examples/demo/src/main/webapp/WEB-INF/portlet.xml Fri Dec 5 14:11:05 2008
@@ -1,61 +1,61 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<portlet-app version="1.0"
- xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
-
- <portlet>
- <description lang="EN">MyFaces Portlet Bridge Demo Portlet</description>
- <portlet-name>portlet-bridge-demo</portlet-name>
- <display-name lang="EN">MyFaces Portlet Bridge Demo</display-name>
- <portlet-class>javax.portlet.faces.GenericFacesPortlet</portlet-class>
-
- <init-param>
- <name>javax.portlet.faces.defaultViewId.view</name>
- <value>/index.jsp</value>
- </init-param>
-
- <init-param>
- <name>javax.portlet.faces.defaltViewId.edit</name>
- <value>/edit.jsp</value>
- </init-param>
-
- <init-param>
- <name>javax.portlet.faces.defaultViewId.help</name>
- <value>/help.jsp</value>
- </init-param>
-
- <supports>
- <mime-type>text/html</mime-type>
- <portlet-mode>edit</portlet-mode>
- <portlet-mode>view</portlet-mode>
- <portlet-mode>help</portlet-mode>
- </supports>
-
- <supported-locale>en</supported-locale>
-
- <portlet-info>
- <title>MyFaces Portlet Bridge Demo</title>
- <short-title>Bridge Demo</short-title>
- </portlet-info>
- </portlet>
-
-</portlet-app>
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific xml:language governing permissions and limitations
+ under the License.
+-->
+<portlet-app version="1.0"
+ xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
+
+ <portlet>
+ <description xml:lang="EN">MyFaces Portlet Bridge Demo Portlet</description>
+ <portlet-name>portlet-bridge-demo</portlet-name>
+ <display-name xml:lang="EN">MyFaces Portlet Bridge Demo</display-name>
+ <portlet-class>javax.portlet.faces.GenericFacesPortlet</portlet-class>
+
+ <init-param>
+ <name>javax.portlet.faces.defaultViewId.view</name>
+ <value>/index.jsp</value>
+ </init-param>
+
+ <init-param>
+ <name>javax.portlet.faces.defaltViewId.edit</name>
+ <value>/edit.jsp</value>
+ </init-param>
+
+ <init-param>
+ <name>javax.portlet.faces.defaultViewId.help</name>
+ <value>/help.jsp</value>
+ </init-param>
+
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>edit</portlet-mode>
+ <portlet-mode>view</portlet-mode>
+ <portlet-mode>help</portlet-mode>
+ </supports>
+
+ <supported-locale>en</supported-locale>
+
+ <portlet-info>
+ <title>MyFaces Portlet Bridge Demo</title>
+ <short-title>Bridge Demo</short-title>
+ </portlet-info>
+ </portlet>
+
+</portlet-app>
Modified: myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java?rev=723896&r1=723895&r2=723896&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java (original)
+++ myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java Fri Dec 5 14:11:05 2008
@@ -27,6 +27,7 @@
import java.util.Map;
import javax.faces.FacesException;
import javax.faces.FactoryFinder;
+import javax.faces.application.FacesMessage;
import javax.faces.application.StateManager;
import javax.faces.application.ViewHandler;
import javax.faces.application.ViewHandlerWrapper;
@@ -38,6 +39,7 @@
import javax.faces.render.RenderKitFactory;
import javax.portlet.PortletContext;
+import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.faces.Bridge;
import javax.portlet.faces.BridgeUtil;
@@ -94,37 +96,100 @@
}
}
- return super.getActionURL(context, viewId);
+ // Faces can't do suffix mapping (extension mapping) properly if there is a query string
+ int qsLoc = viewId.indexOf('?');
+ if (qsLoc < 0) qsLoc = viewId.length();
+
+ String actionURL = super.getActionURL(context, viewId.substring(0, qsLoc));
+ if (qsLoc < viewId.length())
+ actionURL = actionURL.concat(viewId.substring(qsLoc));
+
+ return actionURL;
}
@Override
public UIViewRoot createView(FacesContext facesContext, String viewId)
{
+ // The Bridge extends Faces navigation rule support in that it
+ // allows a to-view-id element to contain an EL expression.
+ // 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() && viewId.startsWith("#"))
{
- return super.createView(facesContext, viewId);
+ // evaluate this as an EL expression
+ viewId = (String) facesContext.getApplication().evaluateExpressionGet(facesContext, viewId, String.class);
+ if (viewId == null)
+ {
+ //TODO: at least log an error.
+ }
}
+
+ UIViewRoot viewRoot = null;
+
+ // The bridge allows viewIds to carry querystrings -- e.g. a qs that has the
+ // mode parameter. Unfortunately, underlying Faces impls don't expect any query
+ // string when mapping from the viewId to the view -- in particular they don't
+ // account for the query string when the Faces servlet is suffix mapped (extension
+ // mapped). So strip the query string here -- create the view and add back
+ int qsLoc = viewId.indexOf('?');
+ if (qsLoc < 0)
+ qsLoc = viewId.length();
- UIViewRoot viewRoot = super.createView(facesContext, viewId);
+ viewRoot = super.createView(facesContext, viewId.substring(0, qsLoc));
+ if (qsLoc < viewId.length())
+ {
+ viewRoot.setViewId(viewRoot.getViewId().concat(viewId.substring(qsLoc)));
+ }
+
+ if (BridgeUtil.isPortletRequest())
+ {
+ // Use the delegatees UIViewRoot if its not the native Faces one
+ // or it already implements the PortletNamingContainer behavior
+ if ((viewRoot.getClass() == UIViewRoot.class) &&
+ (viewRoot.getClass().getAnnotation(PortletNamingContainer.class) == null))
+ {
+ return new PortletNamingContainerUIViewRoot(viewRoot);
+ }
+ }
+
+ return viewRoot;
- // Use the delegatees UIViewRoot if its not the native Faces one
- // or it already implements the PortletNamingContainer behavior
- if ((viewRoot.getClass() != UIViewRoot.class) ||
- (viewRoot.getClass().getAnnotation(PortletNamingContainer.class) != null))
+ }
+
+
+ @Override
+ public UIViewRoot restoreView(FacesContext context, String viewId)
+ {
+ /* Because Faces doesn't support saving a view following an action, the bridge
+ * caches the view and restores the view from the cache for the first render.
+ * Once a render occurs the view is saved/restored from the Faces StateManager.
+ * The view(root) is cached in the bridge request scope which means that
+ * by the time we are asked to restore here, the view(root) is a request
+ * attribute. Logic below merely checks to see if this attribute exists.
+ * If it does it removes the attribute from the request scope ensuring it
+ * won't be used in the future and then returns it. Otherwise it delegates to
+ * the regular Faces restoration process.
+ */
+
+ Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
+ UIViewRoot viewRoot = (UIViewRoot) requestMap.get(BridgeImpl.FACES_VIEWROOT);
+ if (viewRoot != null)
{
- return viewRoot;
+ // remove from current Request Scope
+ requestMap.remove(BridgeImpl.FACES_VIEWROOT);
}
else
{
- return new PortletNamingContainerUIViewRoot(viewRoot);
+ viewRoot = super.restoreView(context, viewId);
}
-
+
+ return viewRoot;
}
-
@Override
public void renderView(FacesContext context, UIViewRoot viewToRender) throws IOException,
FacesException
@@ -448,7 +513,7 @@
// First check to see if there is one set in the configuration - if so test it first
String marker = ((PortletContext)FacesContext.getCurrentInstance().
getExternalContext().getContext()).getInitParameter(Bridge.SAVESTATE_FIELD_MARKER);
-
+
if (isMarker(marker))
{
return marker;
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=723896&r1=723895&r2=723896&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 Fri Dec 5 14:11:05 2008
@@ -105,10 +105,13 @@
public static final String REDIRECT_VIEWPARAMS = "org.apache.myfaces.portlet.faces.redirectViewParams";
public static final String RENDER_REDIRECT_VIEWPARAMS = "org.apache.myfaces.portlet.faces.renderRedirectViewParams";
+ // public so other parts of the impl can access the portletName to access portlet specific context attrs
+ public static final String PORTLET_NAME_ATTRIBUTE = "org.apache.myfaces.portlet.faces.portletName";
+
private static final String REQUEST_SCOPE_LOCK = "org.apache.myfaces.portlet.faces.requestScopeLock";
private static final String REQUEST_SCOPE_MAP = "org.apache.myfaces.portlet.faces.requestScopeMap";
private static final String REQUEST_SCOPE_LISTENER = "org.apache.myfaces.portlet.faces.requestScopeWatch";
- private static final String FACES_VIEWROOT = "org.apache.myfaces.portlet.faces.includeInScope.facesViewRoot";
+ public static final String FACES_VIEWROOT = "org.apache.myfaces.portlet.faces.includeInScope.facesViewRoot";
private static final String FACES_MESSAGES = "org.apache.myfaces.portlet.faces.includeInScope.facesMessages";
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";
@@ -239,6 +242,9 @@
// instanceof which can fail if a portlet container uses a single class
// to implement both the action and render request/response objects
request.setAttribute(Bridge.PORTLET_LIFECYCLE_PHASE, Bridge.PortletPhase.ACTION_PHASE);
+
+ // Set the PortletName for use throughout this request to read portlet specific context attrs
+ request.setAttribute(PORTLET_NAME_ATTRIBUTE, mPortletConfig.getPortletName());
// Set the FacesServletMapping attribute so the ExternalContext can
// pick it up and use it to reverse map viewIds to paths
@@ -338,10 +344,6 @@
finally
{
dumpScopeId(scopeId, "ACTION_PHASE");
- // our servletrequestattributelistener uses this as an indicator of whether
- // its actively working on a request -- remove it to indicate we are done
- request.removeAttribute(Bridge.PORTLET_LIFECYCLE_PHASE);
-
if (context != null)
{
@@ -355,6 +357,10 @@
context.getExternalContext().getSessionMap().remove(BridgeImpl.RENDER_REDIRECT_VIEWPARAMS);
context.release();
}
+
+ // our servletrequestattributelistener uses this as an indicator of whether
+ // its actively working on a request -- remove it to indicate we are done
+ request.removeAttribute(Bridge.PORTLET_LIFECYCLE_PHASE);
}
}
@@ -431,6 +437,9 @@
// to implement both the action and render request/response objects
request.setAttribute(Bridge.PORTLET_LIFECYCLE_PHASE, Bridge.PortletPhase.RENDER_PHASE);
+ // Set the PortletName for use throughout this request to read portlet specific context attrs
+ request.setAttribute(PORTLET_NAME_ATTRIBUTE, mPortletConfig.getPortletName());
+
// Set the FacesServletMapping attribute so the ExternalContext can
// pick it up and use it to reverse map viewIds to paths
if (mFacesMappings != null)
@@ -504,11 +513,6 @@
// VIEW_STATE
// parameter -- always attempt a restore
extRequest = restoreActionParams(context);
-
- // only restores if first render after action
- // afterwards not restored from Bridge request scope
- // rather its saved/restored by Faces.
- restoreFacesView(context, scopeId);
}
// Ensure the ContentType is set before rendering
@@ -539,7 +543,7 @@
removeRequestScopes(scopeId);
}
- mPortletConfig.getPortletContext().log("Exception thrown in doFacesRequest:render", e);
+ mPortletConfig.getPortletContext().log("Exception thrown in doFacesRequest:render: " + e.getMessage() + " : " + e.toString());
if (!(e instanceof BridgeException))
{
Throwable rootCause = e.getCause();
@@ -553,16 +557,18 @@
finally
{
dumpScopeId(scopeId, "RENDER_PHASE");
- // our servletrequestattributelistener uses this as an indicator of whether
- // its actively working on a request -- remove it to indicate we are done
- request.removeAttribute(Bridge.PORTLET_LIFECYCLE_PHASE);
+
if (context != null)
{
context.release();
}
+
+ // our servletrequestattributelistener uses this as an indicator of whether
+ // its actively working on a request -- remove it to indicate we are done
+ request.removeAttribute(Bridge.PORTLET_LIFECYCLE_PHASE);
}
}
-
+
private boolean hasModeChanged(RenderRequest request, QueryString renderRedirectParams)
{
boolean hasModeChanged = false;
@@ -644,18 +650,7 @@
}
else
{
- // using the cached view. Still call the preRestoreView phase listeners
- // as some extensions depend on this being called per request.
- PhaseListener[] listeners = lifecycle.getPhaseListeners();
- PhaseEvent event = new PhaseEvent(context, PhaseId.RESTORE_VIEW, lifecycle);
- for (PhaseListener listener:listeners)
- {
- if (listener.getPhaseId() == PhaseId.ANY_PHASE ||
- listener.getPhaseId() == PhaseId.RESTORE_VIEW)
- {
- listener.beforePhase(event);
- }
- }
+ throw new BridgeException("Shouldn't get here -- disabled cached restore.");
}
// check here to see if a redirect occurred -- if so rerun doFacesRequest
@@ -958,7 +953,7 @@
FacesContext context = null;
context =
- getFacesContextFactory().getFacesContext(mPortletConfig, request, response, lifecycle);
+ getFacesContextFactory().getFacesContext(mPortletConfig.getPortletContext(), request, response, lifecycle);
if (redirectParams != null)
{
@@ -1010,22 +1005,6 @@
requestMap.put(FACES_VIEWROOT, context.getViewRoot());
}
- private void restoreFacesView(FacesContext context, String scopeId)
- {
- Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
- UIViewRoot viewRoot = (UIViewRoot) requestMap.get(FACES_VIEWROOT);
- if (viewRoot != null)
- {
- context.setViewRoot(viewRoot);
- // remove from current Request Scope and the saved Bridge Request
- // Scope
- requestMap.remove(FACES_VIEWROOT);
- removeFromBridgeRequestScopeData(context, scopeId, FACES_VIEWROOT);
- }
- restoreFacesMessageState(context);
- // Don't remove the messages as Faces doesn't save these during render
- }
-
private void saveActionParams(FacesContext context)
{
// Always preserve the FACES_VIEW_STATE parameter as per spec.
@@ -1033,7 +1012,7 @@
ExternalContext ec = context.getExternalContext();
Map<String, Object> requestMap = ec.getRequestMap();
Map<String, String[]> requestParameterMap = ec.getRequestParameterValuesMap();
- if (mPreserveActionParams == Boolean.FALSE)
+ if (mPreserveActionParams.equals(Boolean.FALSE))
{
if (requestMap != null && requestParameterMap != null &&
requestParameterMap.containsKey(ResponseStateManager.VIEW_STATE_PARAM))
@@ -1049,10 +1028,11 @@
// place the parameter map in the portlet request scope
// so it will be promoted into the Bridge's request scope and hence
// be available during render.
- requestMap.put(REQUEST_PARAMETERS, requestParameterMap);
+ Map<String, String[]> mutableParams = new HashMap<String, String[]>(requestParameterMap);
+ requestMap.put(REQUEST_PARAMETERS, mutableParams);
}
}
-
+
private void updateViewInfo(
FacesContext context,
String scopeId)
@@ -1105,11 +1085,16 @@
// finally update the value in the Map
requestParams.put(ResponseStateManager.VIEW_STATE_PARAM, values);
}
+
+ // If this is the first render after an action the cached view will also
+ // be in the scope. Remove it so its not used again.
+ // get the managedScopeMap
+ scopeMap.remove(FACES_VIEWROOT);
}
}
- private LRUMap createRequestScopeMap(PortletContext portletContext)
+ private LRUMap createRequestScopeMap(PortletContext portletContext)
{
// see if portlet has defined how many requestScopes to manage
// for this portlet
@@ -1166,7 +1151,7 @@
}
}
- public void restoreFacesMessageState(FacesContext context)
+ private void restoreFacesMessageState(FacesContext context)
{
// Only restore for Render request
if (context.getExternalContext().getRequest() instanceof RenderRequest)
@@ -1178,7 +1163,7 @@
if (state != null)
{
- for(String clientId:state.getClientIds())
+ for (String clientId:state.getClientIds())
{
for (FacesMessage message:state.getMessages(clientId))
{
@@ -1245,18 +1230,18 @@
{
Map<String, Object> copy = new HashMap<String, Object>(m.size());
- for (Map.Entry<String, Object> entry:m.entrySet())
- {
+ for (Map.Entry<String, Object> entry:m.entrySet())
+ {
// TODO -- restore the ACTION PARAMS if there
// Don't copy any of the portlet or Faces objects
String key = entry.getKey();
Object value = entry.getValue();
- if(!isExcludedFromBridgeRequestScope(key, value, preExistingList))
+ if (!isExcludedFromBridgeRequestScope(key, value, preExistingList))
{
copy.put(key, value);
}
- }
+ }
return copy;
}
@@ -1265,7 +1250,7 @@
{
return Collections.list((Enumeration<String>) request.getAttributeNames());
}
-
+
private boolean isExcludedFromBridgeRequestScope(String key, Object value, List<String> preExistingList)
{
return ((value.getClass().getAnnotation(ExcludeFromManagedRequestScope.class) != null) ||
@@ -1466,7 +1451,7 @@
throws IOException
{
- // First reset the no scope flas as we only care about the
+ // First reset the no scope flag as we only care about the
// action result
context.getExternalContext().getRequestMap().put(
PortletExternalContextImpl.NO_SCOPE, Boolean.FALSE);
@@ -1492,7 +1477,7 @@
// notify this scope's attributes that they are being removed
private void notifyPreDestroy(Map<String, Object> scope)
{
- Set<Map.Entry<String, Object>> s = scope.entrySet();
+ Set<Map.Entry<String, Object>> s = scope.entrySet();
Iterator<Map.Entry<String, Object>> i = s.iterator();
while (i.hasNext())
{
@@ -1597,7 +1582,10 @@
// only set renderresponse if in RESTORE_VIEW phase
if (event.getPhaseId() == PhaseId.RESTORE_VIEW)
{
- event.getFacesContext().renderResponse();
+ FacesContext context = event.getFacesContext();
+ // Now restore the Faces Messages
+ restoreFacesMessageState(context);
+ context.renderResponse();
}
}
@@ -1630,7 +1618,7 @@
return false;
}
- public Map<String,Object> remove(String key)
+ public Map<String,Object> remove(String key)
{
dumpScopeId(key, "RemovePhase");
Map<String, Object> o = super.remove(key);
@@ -1640,7 +1628,7 @@
notifyPreDestroy(o);
return o;
}
-
+
public Map<String,Object> put(String key, Map<String, Object> value)
{
Map<String,Object> o = super.put(key, value);
@@ -1648,7 +1636,7 @@
// Method in the outer BridgeImpl class
if (o != null)
notifyPreDestroy(o);
- return o;
+ return o;
}
}
Modified: myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/FacesContextFactoryImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/FacesContextFactoryImpl.java?rev=723896&r1=723895&r2=723896&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/FacesContextFactoryImpl.java (original)
+++ myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/FacesContextFactoryImpl.java Fri Dec 5 14:11:05 2008
@@ -23,11 +23,10 @@
import javax.faces.context.FacesContext;
import javax.faces.context.FacesContextFactory;
import javax.faces.lifecycle.Lifecycle;
-import javax.portlet.PortletConfig;
+import javax.portlet.PortletContext;
import javax.portlet.PortletRequest;
import javax.portlet.PortletResponse;
import javax.portlet.faces.Bridge;
-import javax.portlet.faces.BridgeUtil;
import javax.servlet.ServletRequest;
/**
@@ -46,7 +45,7 @@
}
@Override
- public FacesContext getFacesContext(Object config, Object request, Object response,
+ public FacesContext getFacesContext(Object context, Object request, Object response,
Lifecycle lifecycle) throws FacesException
{
// if in portlet environment -- do a portlet container neutral test
@@ -56,11 +55,11 @@
if (isPortletRequest(request))
{
// make sure they passed the right objects
- if (config instanceof PortletConfig && request instanceof PortletRequest
+ if (context instanceof PortletContext && request instanceof PortletRequest
&& response instanceof PortletResponse)
{
return new PortletFacesContextImpl(
- new PortletExternalContextImpl((PortletConfig) config,
+ new PortletExternalContextImpl((PortletContext) context,
(PortletRequest) request,
(PortletResponse) response),
lifecycle);
@@ -73,7 +72,7 @@
else
{
// otherwise, delegate
- return mHandler.getFacesContext(config, request, response, lifecycle);
+ return mHandler.getFacesContext(context, request, response, lifecycle);
}
}
Modified: myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java?rev=723896&r1=723895&r2=723896&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java (original)
+++ myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java Fri Dec 5 14:11:05 2008
@@ -42,6 +42,8 @@
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
+import javax.faces.render.ResponseStateManager;
+
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletConfig;
@@ -94,12 +96,13 @@
// Render parameter to store the viewId
public static final String JSF_TARGET_VIEWID_RENDER_PARAMETER = "__jpfbJSFTARGET";
public static final String NO_SCOPE = "org.apache.myfaces.portlet.faces.noScope";
-
+
private PortletContext mPortletContext;
- private PortletConfig mPortletConfig;
private PortletRequest mPortletRequest;
private PortletResponse mPortletResponse;
+
+ private String mPortletName;
// Needed for dispatch() which requires the actual PortletRequest/Response
// objects not wrapped one's (since wrapping isn't official in 168)
@@ -133,14 +136,15 @@
@SuppressWarnings("unchecked")
- public PortletExternalContextImpl(PortletConfig portletConfig, PortletRequest portletRequest,
+ public PortletExternalContextImpl(PortletContext portletContext, PortletRequest portletRequest,
PortletResponse portletResponse)
throws FacesException
{
- mPortletConfig = portletConfig;
- mPortletContext = mPortletConfig.getPortletContext();
+ mPortletContext = portletContext;
mPortletRequest = mOrigPortletRequest = portletRequest;
mPortletResponse = mOrigPortletResponse = portletResponse;
+
+ mPortletName = (String) mPortletRequest.getAttribute(BridgeImpl.PORTLET_NAME_ATTRIBUTE);
mFacesMappings = (List<String>) mPortletRequest.getAttribute(FACES_MAPPING_ATTRIBUTE);
@@ -151,7 +155,6 @@
public void release()
{
- mPortletConfig = null;
mPortletContext = null;
mPortletRequest = null;
mPortletResponse = null;
@@ -907,12 +910,18 @@
*/
@Override
public void setRequestCharacterEncoding(String encoding)
- throws UnsupportedEncodingException, IllegalStateException
+ throws UnsupportedEncodingException
{
if (getPortletPhase() == Bridge.PortletPhase.ACTION_PHASE)
{
- ((ActionRequest) mPortletRequest).setCharacterEncoding(encoding);
+ try
+ {
+ ((ActionRequest) mPortletRequest).setCharacterEncoding(encoding);
+ } catch (IllegalStateException e)
+ {
+ // Swallow this exception and proceed as if a noop.
+ }
}
// Though can only do this operation in a PortletAction Faces impls have
@@ -1121,7 +1130,7 @@
}
// End of JSF 1.2 API
-
+
private Bridge.PortletPhase getPortletPhase()
{
return (Bridge.PortletPhase) getRequestMap().get(Bridge.PORTLET_LIFECYCLE_PHASE);
@@ -1183,7 +1192,7 @@
if (viewId == null)
{
Map<String, String> m = (Map<String,String>) mPortletContext.getAttribute(
- Bridge.BRIDGE_PACKAGE_PREFIX + mPortletConfig.getPortletName()
+ Bridge.BRIDGE_PACKAGE_PREFIX + mPortletName
+ "." + Bridge.DEFAULT_VIEWID_MAP);
viewId = m.get(requestedMode);
if (viewId == null)
@@ -1237,7 +1246,7 @@
}
// If the mode changes mark this so BridgeImpl (controller) can see it shouldn't
- // restotre/save the scope
+ // restore/save the scope
this.getRequestMap().put(NO_SCOPE, Boolean.valueOf(modeChanged));
return viewId;
@@ -1262,8 +1271,9 @@
while (i.hasNext())
{
Map.Entry<String,String[]> e = i.next();
- // only add is not a viewId parameter
- if (!e.getKey().equals(JSF_TARGET_VIEWID_RENDER_PARAMETER))
+ // only add if not a viewId or viewState parameter
+ if (!e.getKey().equals(JSF_TARGET_VIEWID_RENDER_PARAMETER)
+ && !e.getKey().equals(ResponseStateManager.VIEW_STATE_PARAM))
{
for (String s : e.getValue())
{
@@ -1580,7 +1590,7 @@
// so set the attribute they expect with the appropriate info.
this.getRequestMap().put("com.sun.faces.INVOCATION_PATH", mapping);
}
-
+
private boolean isPortletURL(String url)
{
// Quick check for most common case
@@ -1645,19 +1655,6 @@
return true;
}
- private boolean isFacesURL(String url)
- {
- String viewId = null;
-
- // Determine the viewId by inspecting the URL
- if (isRelativePath(url))
- {
- url = getPathFromRelativePath(url);
- }
-
- return getViewIdFromPath(url) != null;
- }
-
private boolean isDirectLink(String url)
{
return isTokenLink(Bridge.DIRECT_LINK, url);
Modified: myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java?rev=723896&r1=723895&r2=723896&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java (original)
+++ myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java Fri Dec 5 14:11:05 2008
@@ -21,11 +21,9 @@
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Map;
import javax.el.ELContext;
import javax.el.ELContextEvent;