public void writeContent(FacesContext context, BufferedMimeResponseWrapper wrappedResponse) throws IOException {
MimeResponse response = wrappedResponse.getResponse();
if(wrappedResponse.isUseWriter()){
FastPrintWriter fastPrintWriter = wrappedResponse.getWriter();
Reader reader = new CharArrayReader(fastPrintWriter.toCharArray());
HtmlParser htmlParser = null;
try {
// TODO - check viewId
htmlParser = getParser("text/xml", true, context.getViewRoot().getViewId());
// Setup scripts and styles
Node[] headEvents = (Node[]) context.getExternalContext().getRequestMap()
.get(AjaxContext.HEAD_EVENTS_PARAMETER);
htmlParser.setHeadNodes(headEvents);
htmlParser.setDoctype(getPublicid());
htmlParser.setViewState((String) context.getExternalContext().getRequestMap()
.get(AjaxViewHandler.SERIALIZED_STATE_KEY));
htmlParser.parseHtml(reader, response.getWriter());
} finally {
reuseParser(htmlParser);
}
}
// TODO - code for output stream.