}
catch (Exception e)
{
if (!(e instanceof BridgeException))
{
e = new BridgeException(e);
}
throw (BridgeException) e;
}
}
// Otherwise this is a Faces resource
// must wait until after init to get at the session
// since view mode mapping must always exist -- check it
StringBuffer keyBuf = new StringBuffer(30);
String key = keyBuf.append(Bridge.VIEWID_HISTORY).append(".view").toString();
if (request.getPortletSession().getAttribute(key) == null)
{
initViewHistoryDefaults(request.getPortletSession(), mDefaultViewIdMap);
}
// Set the PortletName for use throughout this request to read portlet specific context attrs
request.setAttribute(PORTLET_NAME_ATTRIBUTE, mPortletConfig.getPortletName());
// Set the FacesServletMapping attribute so the ExternalContext can
// pick it up and use it to reverse map viewIds to paths
if (mFacesMappings != null)
{
request.setAttribute(PortletExternalContextImpl.FACES_MAPPING_ATTRIBUTE, mFacesMappings);
}
// cache names of existing request attributes so can exclude them
// from being saved in the bridge's request scope. Note: this is done
// before
// acquiring the FacesContext because its possible (though unlikely)
// the application has inserted itself in this process and sets up
// needed request attributes.
List<String> preExistingAttributes = getRequestAttributes(request);
// place on the request for use here and in the servletRequestAttributeListener
if (preExistingAttributes != null)
{
request.setAttribute(PREEXISTING_ATTRIBUTE_NAMES, preExistingAttributes);
}
String scopeId = getRequestScopeId(request);
if (scopeId == null)
{
// first request is a resource request
// create a scope and store in the session until an action occurs
// pass null as we aren't a StateAwareResponse
scopeId = initBridgeRequestScope(request, null);
}
FacesContext context = null;
try
{
// Get the FacesContext instance for this request
Lifecycle lifecycle = getLifecycle();
context = getFacesContext(request, response, lifecycle, null);
ExternalContext extCtx = context.getExternalContext();
// Use request from ExternalContext in case its been wrapped by an
// extension
ResourceRequest extRequest = (ResourceRequest) extCtx.getRequest();
// ensure that isPostback attribute set if VIEW_STATE param exists
if (extCtx.getRequestParameterValuesMap().containsKey(ResponseStateManager.VIEW_STATE_PARAM))
{
extCtx.getRequestMap().put(Bridge.IS_POSTBACK_ATTRIBUTE, Boolean.TRUE);
}
doFacesRender(request, response, context, lifecycle, scopeId, preExistingAttributes);
}
catch (Exception e)
{
// When exception occurs remove stored scope so don't
// get stuck replaying the error when/if user refreshes
if (scopeId != null)
{
removeRequestScopes(scopeId);
}
context.getExternalContext().log("Exception thrown in doFacesRequest:render", e);
if (!(e instanceof BridgeException))
{
e = new BridgeException(e);
}
throw (BridgeException) e;
}
finally
{