Examples of PreparedTemplate


Examples of org.ajax4jsf.renderkit.compiler.PreparedTemplate

  };
  /* (non-Javadoc)
   * @see org.ajax4jsf.resource.BaseResourceRenderer#send(org.ajax4jsf.resource.InternetResource, org.ajax4jsf.resource.ResourceContext)
   */
  public int send(InternetResource base, ResourceContext context) throws IOException {
    PreparedTemplate template = null;
    CountingOutputWriter countingOutputWriter = new CountingOutputWriter();
    template = getTemplate(base, context);
    FacesContext facesContext = FacesContext.getCurrentInstance();
    boolean _CompressStyleOn = !"false".equals(facesContext.getExternalContext()
                 .getInitParameter(COMPRESS_STYLE_PARAMETER));
    Writer writer = context.getWriter();
    int bytesLength;
    if(null != facesContext) {
      // Create responseWriter.
      String defaultRenderKitId = facesContext.getApplication().getDefaultRenderKitId();
      if (null == defaultRenderKitId) {
        defaultRenderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
      }
      RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
      RenderKit renderKit = renderKitFactory.getRenderKit(facesContext,defaultRenderKitId);
      // TODO - handle response encoding
       
      ResponseWriter responseWriter = renderKit.createResponseWriter(countingOutputWriter,null,"UTF-8");
      facesContext.setResponseWriter(responseWriter);
      responseWriter.startDocument();
     
      // TODO - parameters and mock renderer/component ?
      // for first time, this template only allow skin or faces variables interaction
      template.encode(renderer,facesContext,null);
      responseWriter.endDocument();
      responseWriter.flush();
      responseWriter.close();
     
      if (_CompressStyleOn) {   
View Full Code Here

Examples of org.ajax4jsf.renderkit.compiler.PreparedTemplate

   * @param context
   * @return
   * @throws IOException
   */
  public synchronized PreparedTemplate getTemplate(InternetResource base, ResourceContext context) throws IOException {
    PreparedTemplate template;
    //    if(base.isCacheable()){
          template = (PreparedTemplate) base.getProperty(COMPILED_TEMPLATE_PROPERTY);
    //    }
        if(null == template){
          HtmlCompiler compiler = new HtmlCompiler();
View Full Code Here

Examples of org.ajax4jsf.renderkit.compiler.PreparedTemplate

    return true;
  }

  public Object getData(InternetResource base, FacesContext context, Object data) {
    ResourceContext resourceContext = new FacesResourceContext(context);
    PreparedTemplate template;
    try {
      template = getTemplate(base, resourceContext);
    } catch (IOException e) {
      return null;
    }
    UIComponent component = (UIComponent) (data instanceof UIComponent ? data:null);
    TemplateContext templateContext = new TemplateContext(null,context,component);
    Object value = template.getValue(templateContext);
    if(null == value){
      int hashCode = SkinFactory.getInstance().getSkin(context).hashCode(context);
      value = ByteBuffer.allocate(4).putInt(hashCode).array();
    }
    return value;
View Full Code Here

Examples of org.ajax4jsf.renderkit.compiler.PreparedTemplate

  };
  /* (non-Javadoc)
   * @see org.ajax4jsf.resource.BaseResourceRenderer#send(org.ajax4jsf.resource.InternetResource, org.ajax4jsf.resource.ResourceContext)
   */
  public int send(InternetResource base, ResourceContext context) throws IOException {
    PreparedTemplate template = null;
    template = getTemplate(base, context);
    FacesContext facesContext = FacesContext.getCurrentInstance();
    if(null != facesContext) {
      // Create responseWriter.
      String defaultRenderKitId = facesContext.getApplication().getDefaultRenderKitId();
      if (null == defaultRenderKitId) {
        defaultRenderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
      }
      RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
      RenderKit renderKit = renderKitFactory.getRenderKit(facesContext,defaultRenderKitId);
      // TODO - handle response encoding
      ResponseWriter responseWriter = renderKit.createResponseWriter(context.getWriter(),null,"UTF-8");
      facesContext.setResponseWriter(responseWriter);
      responseWriter.startDocument();
      // TODO - parameters and mock renderer/component ?
      // for first time, this template only allow skin or faces variables interaction
      template.encode(renderer,facesContext,null);
      responseWriter.endDocument();
      responseWriter.flush();
      responseWriter.close();
    } else {
      throw new FacesException("FacesContext for resource from template "+base.getKey()+" is null");
View Full Code Here

Examples of org.ajax4jsf.renderkit.compiler.PreparedTemplate

   * @param context
   * @return
   * @throws IOException
   */
  public synchronized PreparedTemplate getTemplate(InternetResource base, ResourceContext context) throws IOException {
    PreparedTemplate template;
    //    if(base.isCacheable()){
          template = (PreparedTemplate) base.getProperty(COMPILED_TEMPLATE_PROPERTY);
    //    }
        if(null == template){
          HtmlCompiler compiler = new HtmlCompiler();
View Full Code Here

Examples of org.ajax4jsf.renderkit.compiler.PreparedTemplate

    return true;
  }

  public Object getData(InternetResource base, FacesContext context, Object data) {
    ResourceContext resourceContext = new FacesResourceContext(context);
    PreparedTemplate template;
    try {
      template = getTemplate(base, resourceContext);
    } catch (IOException e) {
      return null;
    }
    UIComponent component = (UIComponent) (data instanceof UIComponent ? data:null);
    TemplateContext templateContext = new TemplateContext(null,context,component);
    Object value = template.getValue(templateContext);
    if(null == value){
      int hashCode = SkinFactory.getInstance().getSkin(context).hashCode(context);
      value = ByteBuffer.allocate(4).putInt(hashCode).array();
    }
    return value;
View Full Code Here

Examples of org.ajax4jsf.renderkit.compiler.PreparedTemplate

  private static final RendererBase renderer = new DummyRenderer();
  /* (non-Javadoc)
   * @see org.ajax4jsf.resource.BaseResourceRenderer#send(org.ajax4jsf.resource.InternetResource, org.ajax4jsf.resource.ResourceContext)
   */
  public int send(InternetResource base, ResourceContext context) throws IOException {
    PreparedTemplate template = null;
    CountingOutputWriter countingOutputWriter = new CountingOutputWriter();
    template = getTemplate(base, context);
    FacesContext facesContext = FacesContext.getCurrentInstance();
    boolean _CompressStyleOn = !"false".equals(facesContext.getExternalContext()
                 .getInitParameter(COMPRESS_STYLE_PARAMETER));
    Writer writer = context.getWriter();
    int bytesLength;
    if(null != facesContext) {
      // Create responseWriter.
      String defaultRenderKitId = facesContext.getApplication().getDefaultRenderKitId();
      if (null == defaultRenderKitId) {
        defaultRenderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
      }
//      RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
//      RenderKit renderKit = renderKitFactory.getRenderKit(facesContext,defaultRenderKitId);
//      // TODO - handle response encoding
//       
//      ResponseWriter responseWriter = renderKit.createResponseWriter(countingOutputWriter,null,"UTF-8");
      TextCssResponseWriter responseWriter = new TextCssResponseWriter(writer);
      facesContext.setResponseWriter(responseWriter);
      responseWriter.startDocument();
     
      // TODO - parameters and mock renderer/component ?
      // for first time, this template only allow skin or faces variables interaction
      template.encode(renderer,facesContext,null);
      responseWriter.endDocument();
      responseWriter.flush();
      responseWriter.close();
     
      if (_CompressStyleOn) {   
View Full Code Here

Examples of org.ajax4jsf.renderkit.compiler.PreparedTemplate

  };
  /* (non-Javadoc)
   * @see org.ajax4jsf.resource.BaseResourceRenderer#send(org.ajax4jsf.resource.InternetResource, org.ajax4jsf.resource.ResourceContext)
   */
  public int send(InternetResource base, ResourceContext context) throws IOException {
    PreparedTemplate template = null;
    CountingOutputWriter countingOutputWriter = new CountingOutputWriter();
    template = getTemplate(base, context);
    FacesContext facesContext = FacesContext.getCurrentInstance();
    boolean _CompressStyleOn = !"false".equals(facesContext.getExternalContext()
                 .getInitParameter(COMPRESS_STYLE_PARAMETER));
    Writer writer = context.getWriter();
    int bytesLength;
    if(null != facesContext) {
      // Create responseWriter.
      String defaultRenderKitId = facesContext.getApplication().getDefaultRenderKitId();
      if (null == defaultRenderKitId) {
        defaultRenderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
      }
      RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
      RenderKit renderKit = renderKitFactory.getRenderKit(facesContext,defaultRenderKitId);
      // TODO - handle response encoding
       
      ResponseWriter responseWriter = renderKit.createResponseWriter(countingOutputWriter,null,"UTF-8");
      facesContext.setResponseWriter(responseWriter);
      responseWriter.startDocument();
     
      // TODO - parameters and mock renderer/component ?
      // for first time, this template only allow skin or faces variables interaction
      template.encode(renderer,facesContext,null);
      responseWriter.endDocument();
      responseWriter.flush();
      responseWriter.close();
     
      if (_CompressStyleOn) {   
View Full Code Here

Examples of org.ajax4jsf.renderkit.compiler.PreparedTemplate

   * @return
   * @throws IOException
   */
  public synchronized PreparedTemplate getTemplate(InternetResource base,
      ResourceContext context) throws IOException {
    PreparedTemplate template;
    // if(base.isCacheable()){
    template = (PreparedTemplate) base
        .getProperty(COMPILED_TEMPLATE_PROPERTY);
    // }
    if (null == template) {
View Full Code Here

Examples of org.ajax4jsf.renderkit.compiler.PreparedTemplate

    return true;
  }

  public Object getData(InternetResource base, FacesContext context, Object data) {
    ResourceContext resourceContext = new FacesResourceContext(context);
    PreparedTemplate template;
    try {
      template = getTemplate(base, resourceContext);
    } catch (IOException e) {
      return null;
    }
    UIComponent component = (UIComponent) (data instanceof UIComponent ? data:null);
    TemplateContext templateContext = new TemplateContext(null,context,component);
    Object value = template.getValue(templateContext);
    if(null == value){
        SkinFactory skinFactory = SkinFactory.getInstance();
        int hashCode = skinFactory.getSkin(context).hashCode(context);
        int baseHashCode = skinFactory.getBaseSkin(context).hashCode(context);
        value = ByteBuffer.allocate(4*2).putInt(hashCode).putInt(baseHashCode).array();
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.