*/
public void send(ResourceContext resourceContext, InternetResource resource)
throws IOException {
FacesContext facesContext = FacesContext.getCurrentInstance();
PhaseListener[] phaseListeners = null;
PhaseEvent renderViewEvent = null;
if (null != facesContext) {
Lifecycle facesLifecycle = getFacesLifecycle();
phaseListeners = facesLifecycle.getPhaseListeners();
PhaseEvent restoreViewEvent = new PhaseEvent(facesContext,
PhaseId.RESTORE_VIEW, this);
processPhaseListeners(phaseListeners, restoreViewEvent, true);
// Fix for a http://jira.jboss.org/jira/browse/RF-1056
if (facesContext.getResponseComplete())
return;
// fix for a http://jira.jboss.com/jira/browse/RF-1064 .
// viewRoot can be created outside.
UIViewRoot savedViewRoot = facesContext.getViewRoot();
try {
// create "dummy" viewRoot, to avoid problems in phase
// listeners.
UIViewRoot root = new UIViewRoot();
root.setViewId(resource.getKey());
root.setLocale(Locale.getDefault());
root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
facesContext.setViewRoot(root);
// Invoke after restore view phase listeners
processPhaseListeners(phaseListeners, restoreViewEvent, false);
// Fix for a http://jira.jboss.org/jira/browse/RF-1056
if (!facesContext.getResponseComplete()) {
// Invoke before render view phase listeners
renderViewEvent = new PhaseEvent(facesContext,
PhaseId.RENDER_RESPONSE, this);
processPhaseListeners(phaseListeners, renderViewEvent, true);
sendResource(resourceContext, resource);
processPhaseListeners(phaseListeners, renderViewEvent,
false);