Package org.apache.velocity

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


        }

        VelocityWriter writer = new VelocityWriter(outputs);
        ctx.put("out", writer);
        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


            VelocityContext context = new VelocityContext();
            for (String key : contextParameters.keySet()) {
                context.put(key, contextParameters.get(key));
            }
            StringWriter writer = new StringWriter();
            template.merge(context, writer);

            String result = writer.getBuffer().toString();
            if (logger.isDebugEnabled()) {
              logger.debug("Parse result is: ");
              logger.debug(result);
View Full Code Here

        }
        catch(Exception e)
        {
            throw new ServletException(e);
        }
        template.merge(LocalizedVelocityContext.getCurrent().setRequest(request),
                response.getWriter());
    }
   
    public void setBaseDir(String baseDir)
    {
View Full Code Here

      while (it.hasNext()) {
        String key = it.next();
        context.put(key, this.objectstoput.get(key));
      }
      StringWriter ret = new StringWriter();
      template.merge(context, ret);
      renderedTemplate = ret.toString();
    } catch (ResourceNotFoundException e) {
      throw new CRException(e);
    } catch (ParseErrorException e) {
      throw new CRException(e);
View Full Code Here

      ctx.put("resultsDir", resultsDir);
      ctx.put("logDir", logDir);

      File outFile = new File(outDir, className + ".java");
      FileWriter writer = new FileWriter(outFile);
      t.merge(ctx, writer);
      writer.close();

      System.out.println("Generated " + outFile.getCanonicalPath() + " from template " + template);
    }
    catch(BuildException e) {
View Full Code Here

            Context context = createContext(velocityManager, stack, request,
                    response, finalLocation);
            Writer writer = new OutputStreamWriter(response.getOutputStream(),
                    encoding);

            t.merge(context, writer);

            // always flush the writer (we used to only flush it if this was a
            // jspWriter, but someone asked
            // to do it all the time (WW-829). Since Velocity support is being
            // deprecated, we'll oblige :)
View Full Code Here

            } else {
                velocityWriter.recycle(writer);
            }

            template.merge(context, velocityWriter);

        } catch (Exception error) {
            // Exception occured merging template and model. It is possible
            // that some output has already been written, so we will append the
            // error report to the previous output.
View Full Code Here

            } else {
                velocityWriter.recycle(writer);
            }

            template.merge(velocityContext, velocityWriter);

        } catch (Exception error) {
            // Exception occured merging template and model. It is possible
            // that some output has already been written, so we will append the
            // error report to the previous output.
View Full Code Here

            Writer writer = new OutputStreamWriter(response.getOutputStream(), encoding);


            response.setContentType(contentType);

            t.merge(context, writer);

            // always flush the writer (we used to only flush it if this was a jspWriter, but someone asked
            // to do it all the time (WW-829). Since Velocity support is being deprecated, we'll oblige :)
            writer.flush();
        } catch (Exception e) {
View Full Code Here

            {
                context.put(getBodyContentKey(), getRenderedBody());
            }

            // render the template into the writer
            template.merge(context, out);
        }
        else
        {
            // render the body into the writer
            renderBody(out);
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.