Package org.apache.velocity

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


  protected void serialize(Serializable obj, HttpServletResponse response, String page) throws IOException {
    try {
      Template template = velocityEngine.getTemplate(page);
      Context context = new VelocityContext(new ModelMap(obj));
      template.merge(context, response.getWriter());
    } catch (RuntimeException e) {
      throw e;
    } catch (IOException e) {
      throw e;
    } catch (Exception e) {
View Full Code Here


            // print the class
            Template template =
                Velocity.getTemplate(TEMPLATE_PACKAGE + "main.vm");
            FileWriter fileWriter =
                new FileWriter(new File(jClass.getFilename(outputDir)));
            template.merge(context, fileWriter);
            fileWriter.flush();
            fileWriter.close();

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

        Template template = null;
        template = Velocity.getTemplate(annotation.value());

        OutputStreamWriter writer = new OutputStreamWriter(os);
        template.merge(new VelocityContext(model), writer);
        writer.flush();
    }

    @Override
    public String toString() {
View Full Code Here

    }
    context.put("list", list);
      try {
         Template template = getTemplate(listingsPage + ".vm");
         StringWriter writer = new StringWriter();
         template.merge(context, writer);
         return writer.toString();
      } catch (Exception e) {
        LOG.trace(e.getMessage());
        return DEFAULT_ERROR_500_HTML;
      }
View Full Code Here

    try {
      StringWriter writer = new StringWriter();
      Template template = page.getTemplate("listings.vm");
     
      VelocityContext context = new VelocityContext();
         template.merge(context, writer);
      assertNotNull(writer.toString());
    } catch (Exception e) {
      e.printStackTrace();
      fail();
    }
View Full Code Here

    try {
      StringWriter writer = new StringWriter();
      Template template = page.getTemplate("error500.vm");
     
      VelocityContext context = new VelocityContext();
         template.merge(context, writer);
      assertNotNull(writer.toString());
    } catch (Exception e) {
      fail();
    }
  }
View Full Code Here

    }
    context.put("list", list);
      try {
         Template template = getTemplate(listingsPage + ".vm");
         StringWriter writer = new StringWriter();
         template.merge(context, writer);
         return writer.toString();
      } catch (Exception e) {
        LOG.trace(e.getMessage());
        return DEFAULT_ERROR_500_HTML;
      }
View Full Code Here

    }
      try {
         Template template = getTemplate(
           "error" + exception.getHttpStatus().getStatusCode() + ".vm");
         StringWriter writer = new StringWriter();
         template.merge(context, writer);
         return writer.toString();
      } catch (Exception e) {
        LOG.trace(e.getMessage());
        return DEFAULT_ERROR_500_HTML;
      }
View Full Code Here

    context.put("url", request.getRequestLine().getUri());
    context.put("method", request.getRequestLine().getMethod().toUpperCase(Locale.ENGLISH));
      try {
         Template template = getTemplate(page + ".vm");
         StringWriter writer = new StringWriter();
         template.merge(context, writer);
         return writer.toString();
      } catch (ResourceNotFoundException e) {
        LOG.trace(e.getMessage());
        throw new NotFoundException(e);
      } catch (Exception e) {
View Full Code Here

            templateFile.append( templateName );
            templateFile.append( ".vm" );
            Template template = engine.getTemplate( templateFile.toString() );

            // do the merge
            template.merge( context, writer );
            writer.flush();
        }
        catch ( Exception e )
        {
            throw new JxrException( "Error merging velocity template", 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.