Package org.ajax4jsf.resource

Examples of org.ajax4jsf.resource.CountingOutputWriter


   * @return
   * @throws IOException
   */
  public Object getLabelMarkup(FacesContext context, UIComponent component)
      throws IOException {
    CountingOutputWriter customWriter = new CountingOutputWriter();
    StringBuffer result = null;
    UIComponent label = component.getFacet("label");
    if (label != null) {

      ResponseWriter writer = context.getResponseWriter();

      String defaultRenderKitId = context.getApplication()
      .getDefaultRenderKitId();
      if (null == defaultRenderKitId) {
        defaultRenderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
      }
      RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder
      .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
      RenderKit renderKit = renderKitFactory.getRenderKit(context,
          defaultRenderKitId);

      ResponseWriter responseWriter = renderKit.createResponseWriter(
          customWriter, null, "UTF-8");
      context.setResponseWriter(responseWriter);
      writeScriptBody(context, label, false);
      if (writer != null) {
        context.setResponseWriter(writer);
      }
      result = customWriter.getContent();
    }

    return (result != null) ? new JSLiteral(result.toString())
        : null;
  }
View Full Code Here


   * @param component
   * @return
   */
  public StringBuffer getMarkup(FacesContext context, UIComponent component) {
    StringBuffer result = new StringBuffer();
    CountingOutputWriter customWriter = new CountingOutputWriter();
    try {
      if (hasChildren(component)) {
       
        ResponseWriter writer = context.getResponseWriter();

        String defaultRenderKitId = context.getApplication()
            .getDefaultRenderKitId();
        if (null == defaultRenderKitId) {
          defaultRenderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
        }
        RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder
            .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
        RenderKit renderKit = renderKitFactory.getRenderKit(context,
            defaultRenderKitId);

        ResponseWriter responseWriter = renderKit.createResponseWriter(
            customWriter, null, "UTF-8");
        context.setResponseWriter(responseWriter);
        writeScriptBody(context, component, true);
        result = customWriter.getContent();
       
        if (writer != null) {
          context.setResponseWriter(writer);
        }else {
          HttpServletResponse response = (HttpServletResponse)context.getExternalContext().getResponse();
          PrintWriter wr = response.getWriter();
          if (wr != null) {
            context.setResponseWriter(renderKit.createResponseWriter(wr, null, "UTF-8"));
          }
        }
      } else {
        writeScriptBody(customWriter, (String) component
            .getAttributes().get("label"));
        result = customWriter.getContent();
      }
    } catch (Exception e) {
      log.error("Error occurred during rendering of progress bar label. It switched to empty string", e);
    }

View Full Code Here

   * @return
   * @throws IOException
   */
  public Object getLabelMarkup(FacesContext context, UIComponent component)
      throws IOException {
    CountingOutputWriter customWriter = new CountingOutputWriter();
    StringBuffer result = null;
    UIComponent label = component.getFacet("label");
    try {
      if (label != null) {

        ResponseWriter writer = context.getResponseWriter();

        String defaultRenderKitId = context.getApplication()
            .getDefaultRenderKitId();
        if (null == defaultRenderKitId) {
          defaultRenderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
        }
        RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder
            .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
        RenderKit renderKit = renderKitFactory.getRenderKit(context,
            defaultRenderKitId);

        ResponseWriter responseWriter = renderKit.createResponseWriter(
            customWriter, null, "UTF-8");
        context.setResponseWriter(responseWriter);
        writeScriptBody(context, label, false);
        if (writer != null) {
          context.setResponseWriter(writer);
        }
        result = customWriter.getContent();
      }

    } catch (Exception e) {
      e.getMessage();
    }
View Full Code Here

TOP

Related Classes of org.ajax4jsf.resource.CountingOutputWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.