assertParameters(request, response);
if (log.isLoggable(Level.FINE)) {
log.fine("Start bridge action request processing for portlet "
+ getPortletName());
}
PortletBridgeContext bridgeContext = initRequest(request, response, Bridge.PortletPhase.ACTION_PHASE);
RequestScopeManager requestStateManager = RequestScopeManager.getInstance(request,numberOfRequestScopes);
StateId stateId = requestStateManager
.getStateId(request,response);
bridgeContext.setStateId(stateId);
BridgeRequestScope windowState = new BridgeRequestScope();
bridgeContext.setRequestScope(windowState);
FacesContext facesContext = createFacesContext(request, response);
try {
strategy.beforeActionRequest(facesContext);
processIncomingParameters(facesContext, request);
execute(facesContext);
strategy.afterActionRequestExecute(facesContext);
// save request scope variables and Faces Messages.
if (!facesContext.getResponseComplete()) {
// Setup portlet modes from parameters.
Map<String, String[]> viewIdParameters = bridgeContext.getViewIdParameters();
if (null != viewIdParameters && viewIdParameters.size() > 0) {
processPortletParameters(response, stateId, facesContext,
facesContext.getViewRoot().getViewId(),
viewIdParameters);
}
processOutgoingParameters(facesContext,request,response);
// Save view state for a render phases.
facesContext.getApplication().getStateManager().saveView(
facesContext);
windowState.saveRequest(facesContext, true);
} else {
windowState.reset();
String redirectViewId = bridgeContext.getRedirectViewId();
if (null != redirectViewId) {
windowState.setViewId(redirectViewId);
// Save redirect request parameters.
Map<String, String[]> newRequestParameters = bridgeContext
.getRedirectRequestParameters();
windowState.setRequestParameters(newRequestParameters);
processPortletParameters(response, stateId, facesContext,
redirectViewId, newRequestParameters);
processOutgoingParameters(facesContext,request,response);
}
}
} catch (Exception e) {
// handle exception.
exceptionHandler.processActionException(facesContext, windowState,
e);
} finally {
if (null != bridgeContext.getRedirectViewId() || !facesContext.getResponseComplete()) {
requestStateManager.saveRequestScope(stateId, windowState);
response.setRenderParameter(RequestScopeManager.STATE_ID_PARAMETER, stateId.toString());
}
strategy.afterActionRequest(facesContext);
facesContext.release();