Package org.apache.velocity

Examples of org.apache.velocity.Template.merge()


    context.put("ctxPath", this.request.getContextPath());
    context.put("ctx", result);
    context.put("xctx",request.getSession().getAttribute(HtmlResponseWriter.OPTION_KEY));
    //输出到用户端
    StringWriter writer = new StringWriter();
    template.merge(context, writer);
    String content = writer.toString();
    out.write(content.getBytes());
  }

  /* (non-Javadoc)
 
View Full Code Here


        try {
            String location = (String) ActionContext.getContext().get("template");
            Template template = velocityManager.getVelocityEngine().getTemplate(location);

            Writer writer = pageContext.getOut();
            template.merge(resultContext, writer);
            writer.flush();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            // perform cleanup
View Full Code Here

            //Rendering the content
            VelocityEngine velocityEngine = VelocityManager.getInstance().getVelocityEngine();

            Template template = velocityEngine.getTemplate(decorator.getPage());
            StringWriter tempWriter = new StringWriter();
            template.merge(context, tempWriter);
            String renderResult = tempWriter.toString();

            response.getWriter().print(renderResult);

            while (decorator.getInitParameterNames().hasNext()) {
View Full Code Here

        // 输出到用户端
        OutputStreamWriter fileWriter = new OutputStreamWriter(
            new FileOutputStream(packagePath + outputFileName),
            "UTF-8");
        template.merge(context, fileWriter);
        fileWriter.flush();
        fileWriter.close();
      } catch (Exception e) {
      }
    }
View Full Code Here

    }

    public static String getRenderedTemplateWithoutSwallowingErrors(String templateName, Context context) throws Exception {
        Template template = getTemplate(templateName);
        StringWriter tempWriter = new StringWriter();
        template.merge(context, tempWriter);
        return tempWriter.toString();
    }

    public static Template getTemplate(String templateName) throws Exception {
        VelocityEngine velocityEngine = VelocityManager.getInstance().getVelocityEngine();
View Full Code Here

        try
        {
            Context  ctx = createContext( request, response, context );

            Template template = _engine.getTemplate( path );
            template.merge( ctx, response.getWriter(  ) );
        }
        catch ( ParseErrorException p )
        {
            _log.error( "Unexpected error", p );
            throw new PortletServiceException( "Error in the template", p );
View Full Code Here

    try {
      Template template = Velocity.getTemplate(viewFileName, defaultEncoding);

      if (template != null) {
        Writer writer = douyuContext.getHttpServletResponse().getWriter();
        template.merge(velocityContext, writer);

        //writer.flush();
        //writer.close();
      }
    } catch (ResourceNotFoundException rnfe) {
View Full Code Here

                template = this.velocityEngine.getTemplate(templateFile);
                this.mergedTemplateFiles.add(new File(mergedTemplateLocation));
            }
            this.discoveredTemplates.put(templateFile, template);
        }
        template.merge(velocityContext, output);
    }
   
    /**
     * Loads the internal {@link #velocityContext} from the
     * given Map of template objects.
View Full Code Here

            ctx.put(key, attributes.get(key));
        }

        VelocityWriter writer = new VelocityWriter(outputs);
        try {
            tmpl.merge(ctx, writer);
            writer.close();
        } catch (Exception e) {
            Message msg = new Message("VELOCITY_ENGINE_WRITE_ERRORS", LOG);
            throw new ToolException(msg, e);
        }
View Full Code Here

      } else {
        // no theme, load the standard template
        vtemplate = ve.getTemplate(template, VelocityModule.getInputEncoding());
      }
     
      vtemplate.merge(c, wOut);     
    } catch (MethodInvocationException me) {
      throw new OLATRuntimeException(VelocityHelper.class, "MethodInvocationException occured while merging template: methName:"
          + me.getMethodName() + ", refName:" + me.getReferenceName(), me.getWrappedThrowable());
    } catch (Exception e) {
      throw new OLATRuntimeException(VelocityHelper.class, "exception occured while merging template: " + e.getMessage(), e);
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.