[
https://issues.apache.org/jira/browse/TRINIDAD-1377?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12667477#action_12667477
]
Felix Röthenbacher commented on TRINIDAD-1377:
----------------------------------------------
You are refering to my proposed fix in your comment before. This is how it is
currently in the codebase:
return request instanceof ServletRequest ||
_PORTLET_ACTION_REQUEST_CLASS.isInstance(request);
This also returns true for RenderRequest if the request objects implements
ServletRequest (as it does in the Pluto RI).
I would even suggest to use the portlet bridge functionality to detect which
phase we are in (if in any at all):
public static boolean isAction(final ExternalContext externalContext) {
PortletPhase portletPhase = (PortletPhase)
externalContext.getRequestMap().get(PORTLET_PHASE_REQ_ATTR);
return !PortletPhase.RENDER_PHASE.equals(portletPhase);
}
whereas PORTLET_PHASE_REQ_ATTR is defined as
public final static String PORTLET_PHASE_REQ_ATTR =
"javax.portlet.faces.phase";
This allows us to get rid of all the 'instanceof' class detection. The same
applies for isPortlet():
public static boolean isPortlet(final ExternalContext externalContext)
{
PortletPhase portletPhase = (PortletPhase)
externalContext.getRequestMap().get(PORTLET_PHASE_REQ_ATTR);
return portletPhase != null;
}
This requires that the 'provided' scope in the pom.xml for the
portlet-bridge-api dependency is removed.
> ActionRequest not properly detected.
> ------------------------------------
>
> Key: TRINIDAD-1377
> URL: https://issues.apache.org/jira/browse/TRINIDAD-1377
> Project: MyFaces Trinidad
> Issue Type: Bug
> Components: Portlet
> Affects Versions: 1.2.11-core
> Reporter: Felix Röthenbacher
>
> The method ExternalContextUtils.isAction(final ExternalContext
> externalContext) does not reliably detect an action request.
> If the object returned by ExternalContext.getRequest() implements the
> ServletRequest interface the method above returns
> true. This can also apply for a RenderRequest which is not an ActionRequest.
> The following fixes this:
> /**
> * Returns <code>true</code> if this externalContext represents an
> "action". An action request
> * is any ServletRequest or a portlet ActionRequest. It is assumed that the
> ExternalContext
> *
> * @return a boolean of <code>true</code> if this is a Portlet
> ActionRequest or an non-portlet
> * request.
> */
> public static boolean isAction(final ExternalContext externalContext)
> {
> final Object request = externalContext.getRequest();
> if (_PORTLET_ACTION_REQUEST_CLASS == null)
> {
> _LOG
> .fine("Portlet API's are not on the classpath so isAction will only
> check for servlet request.");
> return request instanceof ServletRequest;
> }
> return (request instanceof ServletRequest &&
> !_PORTLET_RENDER_REQUEST_CLASS.isInstance(request) ||
> _PORTLET_ACTION_REQUEST_CLASS.isInstance(request)) ;
> }
> _PORTLET_RENDER_REQUEST_CLASS has to be properly initialized. Not sure why
> this method checks for ServletRequest.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.