Search in sources :

Example 1 with RenderKitFactory

use of javax.faces.render.RenderKitFactory 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)

Example 2 with RenderKitFactory

use of javax.faces.render.RenderKitFactory in project deltaspike by apache.

the class MockedJsf2TestContainer method initRenderKit.

protected void initRenderKit() {
    RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
    this.renderKit = new MockRenderKit();
    renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, this.renderKit);
}
Also used : MockRenderKit(org.apache.myfaces.test.mock.MockRenderKit) RenderKitFactory(javax.faces.render.RenderKitFactory) MockRenderKitFactory(org.apache.myfaces.test.mock.MockRenderKitFactory)

Aggregations

RenderKitFactory (javax.faces.render.RenderKitFactory)2 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 MockRenderKit (org.apache.myfaces.test.mock.MockRenderKit)1 MockRenderKitFactory (org.apache.myfaces.test.mock.MockRenderKitFactory)1