Package org.apache.velocity

Examples of org.apache.velocity.VelocityContext


        restResponse.write(status, content, viewType);
        throw new RenderFinish();
    }

    public void renderHtml(int status, String path, Map result) {
        VelocityContext context = new VelocityContext();
        copyObjectToMap(result, context);
        StringWriter w = new StringWriter();
        Velocity.mergeTemplate(path, "utf-8", context, w);
        restResponse.write(status, w.toString(), ViewType.html);
    }
View Full Code Here


            restResponse.write(status, toJson(result), viewType);
        } else if (viewType == ViewType.string) {
            restResponse.write(status, result.toString(), viewType);
        } else if (viewType == ViewType.html) {

            VelocityContext context = new VelocityContext();

            copyObjectToMap(result, context);

            StringWriter w = new StringWriter();
            Velocity.mergeTemplate(toUnderscoreCase(getControllerNameWithoutSuffix()) + "/" + toUnderscoreCase(getActionName()) + ".vm", "utf-8", context, w);
View Full Code Here

        if (filterKey == null || "".equals(filterKey)) {
            filterKey = "*:*";
        }

        VelocityContext vc = new VelocityContext();

        KernelHelper kernelHelper = new KernelHelper();
        vc.put("mbctx", kernelHelper);
        vc.put("encoder", new KickSunInHead());
        vc.put(OBJECT_NAME_FILTER_KEY, filterKey);

        if (beanName == null) {
            vc.put("template", "nobean.vm");
        } else {
            try {
                vc.put("beanInfo", new GBeanInfoHelper(kernelHelper, beanName));
            } catch (Exception e) {
                e.printStackTrace();
            }
            vc.put("template", "mbeaninfo.vm");
        }

        renderTemplate(req, res, vc, "index.vm");
    }
View Full Code Here

       
        try {
          Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
         
          // initialize the Velocity context
          final VelocityContext c = new VelocityContext();
          for (Object entryObj : bindings.entrySet()) {
              Map.Entry<?, ?> entry = (Map.Entry<?, ?>) entryObj;
              c.put((String) entry.getKey(), entry.getValue());
          }
 
          // let Velocity evaluate the script, and send the output to the browser
          final String logTag = getClass().getSimpleName();
          Writer w = scriptContext.getWriter();
View Full Code Here

  private final Context velocityContext;
 
  public VelocityHelper(ServletContext servletContext, HttpServletResponse response) {
    this.servletContext = servletContext;
    this.response = response;
    this.velocityContext = new VelocityContext();
  }
View Full Code Here

       
        Template template = engine.getTemplate(templateName);
       
        try {
           
            template.merge(new VelocityContext(attributes), response.getWriter());
           
        } catch (Exception e) {
            throw new RuntimeException("error processing template : " + templateName, e);
        }
    }
View Full Code Here

            for (Feature feature : featureList) {
                VelocityEngine ve = new VelocityEngine();
                ve.init(getProperties());
                Template featureResult = ve.getTemplate("templates/featureReport.vm");
                VelocityContextMap contextMap = VelocityContextMap.of(new VelocityContext());
                contextMap.putAll(getGeneralParameters());
                contextMap.put("parallel", ReportBuilder.isParallel());
                contextMap.put("feature", feature);
                contextMap.put("report_status_colour", ri.getReportStatusColour(feature));
                contextMap.put("scenarios", feature.getElements().toList());
View Full Code Here

    private void generateFeatureOverview() throws Exception {
        VelocityEngine ve = new VelocityEngine();
        ve.init(getProperties());
        Template featureOverview = ve.getTemplate("templates/featureOverview.vm");
        VelocityContextMap contextMap = VelocityContextMap.of(new VelocityContext());
        contextMap.putAll(getGeneralParameters());
        contextMap.put("features", ri.getFeatures());
        contextMap.put("parallel", ReportBuilder.isParallel());
        contextMap.put("total_features", ri.getTotalNumberOfFeatures());
        contextMap.put("total_scenarios", ri.getTotalNumberOfScenarios());
View Full Code Here

    public void generateTagReports() throws Exception {
        for (TagObject tagObject : ri.getTags()) {
            VelocityEngine ve = new VelocityEngine();
            ve.init(getProperties());
            Template featureResult = ve.getTemplate("templates/tagReport.vm");
            VelocityContextMap contextMap = VelocityContextMap.of(new VelocityContext());
            contextMap.putAll(getGeneralParameters());
            contextMap.put("tag", tagObject);
            contextMap.put("time_stamp", ri.timeStamp());
            contextMap.put("report_status_colour", ri.getTagReportStatusColour(tagObject));
            generateReport(tagObject.getTagName().replace("@", "").trim() + ".html", featureResult, contextMap.getVelocityContext());
View Full Code Here

    public void generateTagOverview() throws Exception {
        VelocityEngine ve = new VelocityEngine();
        ve.init(getProperties());
        Template featureOverview = ve.getTemplate("templates/tagOverview.vm");
        VelocityContextMap contextMap = VelocityContextMap.of(new VelocityContext());
        contextMap.putAll(getGeneralParameters());
        contextMap.put("tags", ri.getTags());
        contextMap.put("total_tags", ri.getTotalTags());
        contextMap.put("total_scenarios", ri.getTotalTagScenarios());
        contextMap.put("total_passed_scenarios", ri.getTotalPassingTagScenarios());
View Full Code Here

TOP

Related Classes of org.apache.velocity.VelocityContext

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.