Search in sources :

Example 1 with RenderKit

use of javax.faces.render.RenderKit in project acs-community-packaging by Alfresco.

the class InvokeCommand method setupResponseWriter.

/**
 * setup the JSF response writer.
 */
private ResponseWriter setupResponseWriter(final String mimetype, final HttpServletResponse response, final FacesContext facesContext) throws IOException {
    final OutputStream os = response.getOutputStream();
    final UIViewRoot viewRoot = facesContext.getViewRoot();
    final RenderKitFactory renderFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
    final RenderKit renderKit = renderFactory.getRenderKit(facesContext, viewRoot.getRenderKitId());
    final ResponseWriter writer = renderKit.createResponseWriter(new OutputStreamWriter(os, "UTF-8"), mimetype, "UTF-8");
    facesContext.setResponseWriter(writer);
    // must be text/xml otherwise IE doesn't parse the response properly into responseXML
    response.setContentType(mimetype);
    return writer;
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) OutputStream(java.io.OutputStream) RenderKit(javax.faces.render.RenderKit) OutputStreamWriter(java.io.OutputStreamWriter) UIViewRoot(javax.faces.component.UIViewRoot) RenderKitFactory(javax.faces.render.RenderKitFactory)

Aggregations

OutputStream (java.io.OutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 UIViewRoot (javax.faces.component.UIViewRoot)1 ResponseWriter (javax.faces.context.ResponseWriter)1 RenderKit (javax.faces.render.RenderKit)1 RenderKitFactory (javax.faces.render.RenderKitFactory)1