Package org.apache.velocity.app

Examples of org.apache.velocity.app.VelocityEngine


                htmlPage.writeHead(OutputConverter.getWriter(buffer));
                context.put("head", buffer.toString());
            }

            //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);
View Full Code Here


        template.merge(context, tempWriter);
        return tempWriter.toString();
    }

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

        /*
         * if (velocityEngine == null) { velocityEngine = new VelocityEngine();
         * Properties props = new Properties();
         * props.load(ClassLoaderUtils.getResourceAsStream("test-velocity.properties",
         * com.opensymphony.webwork.portlet.sitemesh.VelocityUtils.class));
         * props.list(System.out); velocityEngine.init(props); }
         */
        String encoding = "UTF-8";

        Template template = velocityEngine.getTemplate(templateName, encoding);
        return template;
    }
View Full Code Here

            throw new IllegalArgumentException(gripe);
        }

        Properties p = loadConfiguration(context);

        VelocityEngine velocityEngine = new VelocityEngine();

        try {
            velocityEngine.init(p);
        } catch (Exception e) {
            String gripe = "Unable to instantiate VelocityEngine!";
            log.error(gripe, e);
            throw new RuntimeException(gripe);
        }
View Full Code Here

    public void testDirectVelocity()
        throws Exception
    {
        StringWriter writer = new StringWriter();

        VelocityEngine engine = new VelocityEngine();
        engine.init();

        VelocityContext velocityContext = new VelocityContext();

        velocityContext.put("test1", "@test1@");
        velocityContext.put("test2", "@test2@");

        assertTrue(engine.evaluate(velocityContext, writer, "mylogtag", "$test1$test2"));
        assertEquals(
            "@test1@@test2@",
            writer.getBuffer().toString());
    }
View Full Code Here

    {
        super.init( serviceConfig );

        try
        {
            _engine = new VelocityEngine(  );
            _engine.init( getProperties( serviceConfig.getServletConfig(  ) ) );
        }
        catch ( Exception e )
        {
            throw new PortletServiceException( e );
View Full Code Here

            engineProperties.addProperty(
                VelocityEngine.VM_LIBRARY,
                iterator.next());
        }

        this.velocityEngine = new VelocityEngine();
        this.velocityEngine.setExtendedProperties(engineProperties);

        if (this.mergeLocation != null)
        {
            // set the file resource path (to the merge location)
View Full Code Here

      }

      this.configMap = map;

      // Initialise velocity engine
      this.ve = new VelocityEngine();

      this.ve.setProperty("runtime.log.logsystem.class",
                             "org.apache.velocity.runtime.log.SimpleLog4JLogSystem");
      this.ve.setProperty("runtime.log.logsystem.log4j.category",
                             log.getName() + ".VelocityEngine");
View Full Code Here

  private MailerWithTemplate() {
    super();
    // init velocity engine
    Properties p = null;
    try {
      velocityEngine = new VelocityEngine();
      p = new Properties();
      // p.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
      // "org.apache.velocity.runtime.log.SimpleLog4JLogSystem");
      // p.setProperty(RuntimeConstants.RUNTIME_LOG,
      // OLATContext.getUserdataRoot() + "logs/velocity-email.log.txt");
View Full Code Here

  public UserBulkChangeManager() {
    // init velocity engine
    Properties p = null;
    try {
      velocityEngine = new VelocityEngine();
      p = new Properties();
      velocityEngine.init(p);
    } catch (Exception e) {
      throw new RuntimeException("config error " + p.toString());
    }
View Full Code Here

  }

  private void init() {
    Properties p = null;
    try {
      ve = new VelocityEngine();
      p = new Properties();
      p.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.SimpleLog4JLogSystem");
      //p.setProperty(RuntimeConstants.RUNTIME_LOG, OLATContext.getUserdataRoot() + "logs/velocity.log.txt");
      p.setProperty("runtime.log.logsystem.log4j.category", "syslog");
View Full Code Here

TOP

Related Classes of org.apache.velocity.app.VelocityEngine

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.