{
log.fine("Start bridge event request processing for portlet "
+ getPortletName());
}
//init bridge context and set PORTLET_LIFECYCLE_PHASE to current portlet phase
PortletBridgeContext bridgeContext = initRequest(request,
response,
Bridge.PortletPhase.EVENT_PHASE);
//get RequestScopeManager which holds STATE_ID parameter and adds
// REQUEST_STATE_MANAGER to PortletSession
RequestScopeManager requestStateManager =
RequestScopeManager.getInstance(request, numberOfRequestScopes);
//get the stateId for this event request, simple init with stateId and randomUUID
StateId stateId = requestStateManager.getStateId(request, response);
//store in bridge context
bridgeContext.setStateId(stateId);
//get the current RequestScope from the stateId otherwise get it form states map
BridgeRequestScope windowState = requestStateManager.getRequestScope(stateId);
//check for failure of pulling it from the RequestScopeManager's map of "states"
if (null == windowState)
{
windowState = new BridgeRequestScope();
}
else
{
windowState.reset();
}
//create the facesContext using facesContextFactory
FacesContext facesContext = createFacesContext(request, response);
try
{
// If strategy enlists Seam, Propagate current render parameters.
//call FacesLifecycle.beginRequest from seamPhaseListenerWrapper
// which will setup up all the contexts, except conversation is null
strategy.beforeEventRequest(facesContext);
//portlet sets render params
response.setRenderParameters(request);
//helper method for setting incoming params as EL variables
processIncomingParameters(facesContext, request);
//execute phases from LifecyclePhase - for actions only
execute(facesContext);
//check for null event handler
if (null == eventHandler)
{
log.severe("The EventHandler is null for " + getPortletName() + ". Ensure " +
"your portlet.xml settings are correct and that you have implemented the " +
"BridgeEventHandler in your application.");
}
//get the event from the request
Event event = request.getEvent();
//Handle the event and get the result
EventNavigationResult result = eventHandler.handleEvent(facesContext, event);
if (result != null)
{
facesContext.getApplication().getNavigationHandler().handleNavigation(facesContext,
result.getFromAction(),
result.getOutcome());
// the navigation rule might indicate a redirect
if (facesContext.getResponseComplete())
{
return;
}
}
//now place view root in request scope.
windowState.setViewRoot(facesContext.getViewRoot());
//set the request scope of this event (aka windowState)
bridgeContext.setRequestScope(windowState);
//helper for removal and addition of PRPs
processOutgoingParameters(facesContext, request, response);
//update stateId in RequestScopeManager and put it on session as REQUEST_STATE_MANAGER