// If there were any "handled" exceptions queued, then throw a BridgeException.
Throwable handledException = getJSF2HandledException(facesContext);
if (handledException != null) {
throw new BridgeException(handledException);
}
// Otherwise, if there were any "unhandled" exceptions queued, then throw a BridgeException.
Throwable unhandledException = getJSF2UnhandledException(facesContext);
if (unhandledException != null) {
throw new BridgeException(unhandledException);
}
// Set a flag on the bridge request scope indicating that the Faces Lifecycle has executed.
bridgeRequestScope.setFacesLifecycleExecuted(true);
// If there is a bridgeEventHandler registered in portlet.xml, then invoke the handler so that it
// can process the event payload.
logger.debug("Invoking {0} for class=[{1}]", bridgeEventHandlerAttributeName,
bridgeEventHandler.getClass());
Event event = eventRequest.getEvent();
EventNavigationResult eventNavigationResult = bridgeEventHandler.handleEvent(facesContext, event);
if (eventNavigationResult != null) {
String oldViewId = facesContext.getViewRoot().getViewId();
String fromAction = eventNavigationResult.getFromAction();
String outcome = eventNavigationResult.getOutcome();
logger.debug("Invoking navigationHandler fromAction=[{0}] outcome=[{1}]", fromAction, outcome);
NavigationHandler navigationHandler = facesContext.getApplication().getNavigationHandler();
navigationHandler.handleNavigation(facesContext, fromAction, outcome);
String newViewId = facesContext.getViewRoot().getViewId();
bridgeRequestScope.setNavigationOccurred(!oldViewId.equals(newViewId));
}
// Save the faces view root and any messages in the faces context so that they can be restored during
// the RENDER_PHASE of the portlet lifecycle.
bridgeRequestScope.saveState(facesContext);
// Assume that the bridge request scope should be maintained from the EVENT_PHASE into the
// RENDER_PHASE by utilizing render parameters.
BridgeRequestScope.Transport bridgeRequestScopeTransport =
BridgeRequestScope.Transport.RENDER_PARAMETER;
Serializable eventPayload = event.getValue();
// FACES-1465: If the portlet developer intentionally wrapped the event payload is with an
// EventPayloadWrapper, then determine whether or not this is happening during a redirect. If this is
// the case, then the bridge request scope must be maintained from the EVENT_PHASE into the RENDER_PHASE
// by utilizing a portlet session attribute. This is because render parameters will not survive a
// redirect.
if ((eventPayload != null) && (eventPayload instanceof EventPayloadWrapper)) {
EventPayloadWrapper eventPayloadWrapper = (EventPayloadWrapper) eventPayload;
if (eventPayloadWrapper.isRedirect()) {
bridgeRequestScopeTransport = BridgeRequestScope.Transport.PORTLET_SESSION_ATTRIBUTE;
}
}
maintainBridgeRequestScope(eventRequest, eventResponse, bridgeRequestScopeTransport);
// Process the outgoing public render parameters.
// TCK TestPage064: eventControllerTest
processOutgoingPublicRenderParameters(facesLifecycle);
}
// Maintain the render parameters set in the ACTION_PHASE so that they carry over to the RENDER_PHASE.
bridgeContext.getPortletContainer().maintainRenderParameters(eventRequest, eventResponse);
// Spec 6.6 (Namespacing)
indicateNamespacingToConsumers(facesContext.getViewRoot(), eventResponse);
}
catch (Throwable t) {
throw new BridgeException(t);
}
finally {
cleanup();
}
}