// 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
{
writer.startDocument();
inDocument = true;
_facesContext.setResponseWriter(writer);
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())
{
Set<VisitHint> hints = new HashSet<VisitHint>();
// unrendered have to be skipped, transient definitely must be added to our list!
hints.add(VisitHint.SKIP_UNRENDERED);
// render=@all, so output the body.
if (renderIds.contains (PartialResponseWriter.RENDER_ALL_MARKER))
{
processRenderAll(viewRoot, writer);
}
else
{
VisitContext visitCtx = VisitContext.createVisitContext(_facesContext, renderIds, hints);
viewRoot.visitTree(visitCtx, new PhaseAwareVisitCallback(_facesContext, phaseId));
}
}
}
// 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(PartialResponseWriter.VIEW_STATE_MARKER);
writer.write(viewState);
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)) {
log.log(Level.SEVERE, "" , ex);
}