try {
// If there is a bridgeEventHandler registered in portlet.xml, then
String bridgeEventHandlerAttributeName = Bridge.BRIDGE_PACKAGE_PREFIX + portletName + "." +
Bridge.BRIDGE_EVENT_HANDLER;
BridgeEventHandler bridgeEventHandler = (BridgeEventHandler) portletContext.getAttribute(
bridgeEventHandlerAttributeName);
init(eventRequest, eventResponse, Bridge.PortletPhase.EVENT_PHASE);
if (bridgeEventHandler != null) {
// Restore the BridgeRequestScope that may have started during the ACTION_PHASE.
bridgeRequestScope.restoreState(facesContext);
// PROPOSED-FOR-BRIDGE3-API: https://issues.apache.org/jira/browse/PORTLETBRIDGE-202
bridgeRequestScope.setPortletMode(eventRequest.getPortletMode());
// Execute the JSF lifecycle so that ONLY the RESTORE_VIEW phase executes (note that this this is
// accomplished by the IPCPhaseListener).
facesLifecycle.execute(facesContext);
// 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();