org.tigris.scarab.services.email
Class VelocityEmail

java.lang.Object
  extended byorg.tigris.scarab.services.email.VelocityEmail

public abstract class VelocityEmail
extends java.lang.Object

This is a simple static accessor to common Velocity tasks such as getting an instance of a context as well as handling a request for processing a template.

 Context context = TurbineVelocity.getContext(data);
 context.put("message", "Hello from Turbine!");
 String results = TurbineVelocity.handleRequest(context, "helloWorld.vm");
 data.getPage().getBody().addElement(results);
 

Version:
$Id: VelocityEmail.java 7859 2003-05-03 22:12:58Z jon $
Author:
John D. McNally, Jon S. Stevens, Jason van Zyl, Michael Stack

Constructor Summary
VelocityEmail()
           
 
Method Summary
protected static VelocityEmailService getService()
          Utility method for accessing the service implementation
static java.lang.String handleRequest(org.apache.velocity.context.Context context, java.lang.String template)
          This allows you to pass in a context and a path to a template file and then grabs an instance of the velocity service and processes the template and returns the results as a String object.
static void handleRequest(org.apache.velocity.context.Context context, java.lang.String template, java.io.OutputStream out)
          Process the request and fill in the template with the values you set in the Context.
static void handleRequest(org.apache.velocity.context.Context context, java.lang.String template, java.io.OutputStream out, java.lang.String charset, java.lang.String encoding)
          Process the request and fill in the template with the values you set in the Context.
 java.lang.String handleRequest(org.apache.velocity.context.Context context, java.lang.String template, java.lang.String charset, java.lang.String encoding)
           
static void handleRequest(org.apache.velocity.context.Context context, java.lang.String filename, java.io.Writer writer)
           
static void handleRequest(org.apache.velocity.context.Context context, java.lang.String filename, java.io.Writer writer, java.lang.String encoding)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VelocityEmail

public VelocityEmail()
Method Detail

getService

protected static VelocityEmailService getService()
Utility method for accessing the service implementation

Returns:
a VelocityEmailService implementation instance

handleRequest

public static java.lang.String handleRequest(org.apache.velocity.context.Context context,
                                             java.lang.String template)
                                      throws java.lang.Exception
This allows you to pass in a context and a path to a template file and then grabs an instance of the velocity service and processes the template and returns the results as a String object.

Parameters:
context - A Context.
template - The path to the template file.
Returns:
The processed template.
Throws:
java.lang.Exception - Error processing template.

handleRequest

public java.lang.String handleRequest(org.apache.velocity.context.Context context,
                                      java.lang.String template,
                                      java.lang.String charset,
                                      java.lang.String encoding)
                               throws java.lang.Exception
Throws:
java.lang.Exception
See Also:
VelocityEmailService.handleRequest(Context, String, String, String)

handleRequest

public static void handleRequest(org.apache.velocity.context.Context context,
                                 java.lang.String template,
                                 java.io.OutputStream out)
                          throws java.lang.Exception
Process the request and fill in the template with the values you set in the Context.

Parameters:
context - A Context.
out - A OutputStream where we will write the process template as a String.
Throws:
java.lang.Exception - Error processing template.
See Also:
VelocityEmailService.handleRequest(Context, String, OutputStream)

handleRequest

public static void handleRequest(org.apache.velocity.context.Context context,
                                 java.lang.String template,
                                 java.io.OutputStream out,
                                 java.lang.String charset,
                                 java.lang.String encoding)
                          throws java.lang.Exception
Process the request and fill in the template with the values you set in the Context.

Parameters:
context - A Context.
template - The path to the template file.
out - A OutputStream where we will write the process template as a String.
charset - The character set to use when writing the result.
encoding - The encoding to use when merging context and template.
Throws:
java.lang.Exception - Error processing template.
See Also:
VelocityEmailService.handleRequest(Context, String, OutputStream)

handleRequest

public static void handleRequest(org.apache.velocity.context.Context context,
                                 java.lang.String filename,
                                 java.io.Writer writer)
                          throws org.apache.fulcrum.ServiceException
Throws:
org.apache.fulcrum.ServiceException
See Also:
VelocityEmailService.handleRequest(Context, String, Writer)

handleRequest

public static void handleRequest(org.apache.velocity.context.Context context,
                                 java.lang.String filename,
                                 java.io.Writer writer,
                                 java.lang.String encoding)
                          throws org.apache.fulcrum.ServiceException
Throws:
org.apache.fulcrum.ServiceException
See Also:
VelocityEmailService.handleRequest(Context, String, Writer, String)


Copyright © 2000-2004 Tigris.org. All Rights Reserved.