Hi John,
John Lewis wrote:
In a few places in the framework, we have code that generally handles
PortletRequest objects, but then may need to do some special logic
depending on if it is an ActionRequest or RenderRequest. In those
cases, we test it with instanceof and proceed accordingly.
Whereabouts in Spring do you perform special logic? I saw this in
FrameworkPortlet's processAction method (but didn't look much further):
if (request instanceof ActionRequest) {
doActionService((ActionRequest) request,
(ActionResponse) response);
}
else {
doRenderService((RenderRequest) request,
(RenderResponse) response);
}
Could you add a parameter to processRequest(PortletRequest,
PortletResponse) which would indicate whether or not it was called from
processAction(ActionRequest, ActionResponse)?
<snip>
Can anyone suggest a better way to detect what kind of request is being
processed when working with a PortletRequest?
My suggestion would be to add a request attribute to the PortletRequest
in Spring's FrameworkPortlet that would indicate it is an ActionRequest.
Or, if the processAction method is the only place where you perform
special logic, modify the method to take a boolean indicating whether or
not it is an action.
Is the way that a lot of
existing code is doing it reasonable and should this portal look to
change it's class structure? Should there be an errata against the
current spec about this issue? Should this be clarified in the JSR-286
spec?
I agree that it is a common assumption and common practice to implement
ActionRequest and RenderRequest separately, and that the instanceof
idiom is common.
Hope this helps, keep up the good work on Spring Portlet - I've been
using it since the m2 days and it has really done wonders for me.
Best,
Elliot
Thanks in advance for your opinions on this topic.
John Lewis