// return;
//}
// note that we cannot use this.getPartialResponseWriter(), because
// this could cause problems if PartialResponseWriter is wrapped
PartialResponseWriter writer = _facesContext.getPartialViewContext().getPartialResponseWriter();
PartialViewContext pvc = _facesContext.getPartialViewContext();
ResponseWriter oldWriter = _facesContext.getResponseWriter();
boolean inDocument = false;
//response type = text/xml
//no caching and no timeout if possible!
ExternalContext externalContext = _facesContext.getExternalContext();
externalContext.setResponseContentType("text/xml");
externalContext.addResponseHeader("Pragma", "no-cache");
externalContext.addResponseHeader("Cache-control", "no-cache");
//under normal circumstances pragma should be enough, IE needs
//a special treatment!
//http://support.microsoft.com/kb/234067
externalContext.addResponseHeader("Expires", "-1");
try
{
String currentEncoding = writer.getCharacterEncoding();
writer.writePreamble("<?xml version=\"1.0\" encoding=\""+
(currentEncoding == null ? "UTF-8" : currentEncoding) +"\"?>");
writer.startDocument();
inDocument = true;
_facesContext.setResponseWriter(writer);
if (isResetValues())
{
viewRoot.resetValues(_facesContext, getRenderIds());
}
if (pvc.isRenderAll())
{
processRenderAll(viewRoot, writer);
}
else
{
Collection<String> renderIds = pvc.getRenderIds();
//Only apply partial visit if we have ids to traverse
if (renderIds != null && !renderIds.isEmpty())
{
// render=@all, so output the body.
if (renderIds.contains(PartialResponseWriter.RENDER_ALL_MARKER))
{
processRenderAll(viewRoot, writer);
}
else
{
List<UIComponent> updatedComponents = null;
if (!ExternalContextUtils.isPortlet(_facesContext.getExternalContext()) &&
MyfacesConfig.getCurrentInstance(externalContext).isStrictJsf2RefreshTargetAjax())
{
RequestViewContext rvc = RequestViewContext.getCurrentInstance(_facesContext);
if (rvc.isRenderTarget("head"))
{
UIComponent head = findHeadComponent(viewRoot);
if (head != null)
{
writer.startUpdate("javax.faces.ViewHead");
head.encodeAll(_facesContext);
writer.endUpdate();
if (updatedComponents == null)
{
updatedComponents = new ArrayList<UIComponent>();
}
updatedComponents.add(head);
}
}
if (rvc.isRenderTarget("body") || rvc.isRenderTarget("form"))
{
UIComponent body = findBodyComponent(viewRoot);
if (body != null)
{
writer.startUpdate("javax.faces.ViewBody");
body.encodeAll(_facesContext);
writer.endUpdate();
if (updatedComponents == null)
{
updatedComponents = new ArrayList<UIComponent>();
}
updatedComponents.add(body);
}
}
}
VisitContext visitCtx = getVisitContextFactory().getVisitContext(
_facesContext, renderIds, PARTIAL_RENDER_HINTS);
viewRoot.visitTree(visitCtx,
new PhaseAwareVisitCallback(_facesContext, phaseId, updatedComponents));
}
}
else if (!ExternalContextUtils.isPortlet(_facesContext.getExternalContext()) &&
MyfacesConfig.getCurrentInstance(externalContext).isStrictJsf2RefreshTargetAjax())
{
RequestViewContext rvc = RequestViewContext.getCurrentInstance(_facesContext);
if (rvc.isRenderTarget("head"))
{
UIComponent head = findHeadComponent(viewRoot);
if (head != null)
{
writer.startUpdate("javax.faces.ViewHead");
head.encodeAll(_facesContext);
writer.endUpdate();
}
}
if (rvc.isRenderTarget("body") || rvc.isRenderTarget("form"))
{
UIComponent body = findBodyComponent(viewRoot);
if (body != null)
{
writer.startUpdate("javax.faces.ViewBody");
body.encodeAll(_facesContext);
writer.endUpdate();
}
}
}
}
// invoke encodeAll() on every UIViewParameter in the view to
// enable every UIViewParameter to save its value in the state
// just like UIViewRoot.encodeEnd() does on a normal request
// (see MYFACES-2645 for details)
Collection<UIViewParameter> viewParams = ViewMetadata.getViewParameters(viewRoot);
if (!viewParams.isEmpty())
{
for (UIViewParameter param : viewParams)
{
param.encodeAll(_facesContext);
}
}
//Retrieve the state and apply it if it is not null.
String viewState = _facesContext.getApplication().getStateManager().getViewState(_facesContext);
if (viewState != null)
{
writer.startUpdate(HtmlResponseStateManager.generateUpdateViewStateId(
_facesContext));
writer.write(viewState);
writer.endUpdate();
}
ClientWindow cw = _facesContext.getExternalContext().getClientWindow();
if (cw != null)
{
writer.startUpdate(HtmlResponseStateManager.generateUpdateClientWindowId(
_facesContext));
writer.write(cw.getId());
writer.endUpdate();
}
}
catch (IOException ex)
{
Logger log = Logger.getLogger(PartialViewContextImpl.class.getName());
if (log.isLoggable(Level.SEVERE))
{
log.log(Level.SEVERE, "", ex);
}
}
finally
{
try
{
if (inDocument)
{
writer.endDocument();
}
writer.flush();
}
catch (IOException ex)
{
Logger log = Logger.getLogger(PartialViewContextImpl.class.getName());
if (log.isLoggable(Level.SEVERE))