}
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request,
HttpServletResponse response) throws Exception {
FacesContextHelper facesContextHelper = new FacesContextHelper();
FacesContext facesContext = facesContextHelper.getFacesContext(getServletContext(), request, response);
populateRequestMap(facesContext, model);
JsfUtils.notifyBeforeListeners(PhaseId.RESTORE_VIEW, this.facesLifecycle, facesContext);
ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
if (!isPortletRequest(facesContext)) {
viewHandler.initView(facesContext);
}
UIViewRoot viewRoot = viewHandler.createView(facesContext, getUrl());
Assert.notNull(viewRoot, "A JSF view could not be created for " + getUrl());
viewRoot.setLocale(RequestContextUtils.getLocale(request));
viewRoot.setTransient(true);
facesContext.setViewRoot(viewRoot);
JsfUtils.notifyAfterListeners(PhaseId.RESTORE_VIEW, this.facesLifecycle, facesContext);
facesContext.setViewRoot(viewRoot);
facesContext.renderResponse();
try {
this.logger.debug("Asking faces lifecycle to render");
this.facesLifecycle.render(facesContext);
} finally {
this.logger.debug("View rendering complete");
facesContextHelper.releaseIfNecessary();
}
}