PortletRequestContextService rcService = getContainerServices().getPortletRequestContextService();
PortletEnvironmentService envService = getContainerServices().getPortletEnvironmentService();
PortletInvokerService invoker = getContainerServices().getPortletInvokerService();
PortletRequestContext requestContext = rcService.getPortletActionRequestContext(this, request, response, portletWindow);
PortletActionResponseContext responseContext = rcService.getPortletActionResponseContext(this, request, response, portletWindow);
ActionRequest portletRequest = envService.createActionRequest(requestContext, responseContext);
ActionResponse portletResponse = envService.createActionResponse(responseContext);
FilterManager filterManager = filterInitialisation(portletWindow,PortletRequest.ACTION_PHASE);
String location = null;
try
{
invoker.action(requestContext, portletRequest, portletResponse, filterManager);
debugWithName("Portlet action processed for: "
+ portletWindow.getPortletDefinition().getPortletName());
// Mark portlet interaction is completed: backend implementation can flush response state now
responseContext.close();
if (!responseContext.isRedirect())
{
List<Event> events = responseContext.getEvents();
if (!events.isEmpty())
{
getContainerServices().getEventCoordinationService().processEvents(this, portletWindow, request, response, events);
}
}
// After processing action and possible event handling, retrieve the target response URL to be redirected to
// This can either be a renderURL or an external URL (optionally containing a future renderURL as query parameter
location = response.encodeRedirectURL(responseContext.getResponseURL());
}
finally
{
responseContext.release();
}
redirect(request, response, location);
debugWithName("Portlet action done for: " + portletWindow.getPortletDefinition().getPortletName());
}