ResponseWriter writer = context.getResponseWriter();
StringWriter dumpingWriter = new StringWriter();
ResponseWriter clonedWriter = writer.cloneWithWriter(dumpingWriter);
context.setResponseWriter(clonedWriter);
TemplateComponent templateComponent = null;
if (component instanceof TemplateComponent) {
templateComponent = (TemplateComponent) component;
}
try {
if (templateComponent != null) {
templateComponent.startTemplateEncode();
}
if (children) {
this.renderChildren(context, component);
} else {
this.renderChild(context, component);
}
} finally {
if (templateComponent != null) {
templateComponent.endTemplateEncode();
}
clonedWriter.flush();
context.setResponseWriter(writer);
}