use of org.apache.myfaces.context.PartialResponseWriterImpl in project myfaces by apache.
the class PartialViewContextImpl method getPartialResponseWriter.
@Override
public PartialResponseWriter getPartialResponseWriter() {
assertNotReleased();
if (_partialResponseWriter == null) {
ResponseWriter responseWriter = context.getResponseWriter();
if (responseWriter == null) {
// ResponseWriter from the RenderKit and then wrap if necessary.
try {
RenderKit renderKit = context.getRenderKit();
if (renderKit == null) {
// If the viewRoot was set to null by some reason, or there is no
// renderKitId on that view, this could be still an ajax redirect,
// so we have to try to calculate the renderKitId and return a
// RenderKit instance, to send the response.
String renderKitId = context.getApplication().getViewHandler().calculateRenderKitId(context);
RenderKitFactory rkf = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
renderKit = rkf.getRenderKit(context, renderKitId);
}
responseWriter = renderKit.createResponseWriter(context.getExternalContext().getResponseOutputWriter(), "text/xml", context.getExternalContext().getRequestCharacterEncoding());
} catch (IOException e) {
throw new IllegalStateException("Cannot create Partial Response Writer", e);
}
}
// createResponseWriter, so we should cast here for it and prevent double wrapping.
if (responseWriter instanceof PartialResponseWriter) {
_partialResponseWriter = (PartialResponseWriter) responseWriter;
} else {
_partialResponseWriter = new PartialResponseWriterImpl(responseWriter);
}
}
return _partialResponseWriter;
}
Aggregations