org.apache.turbine.services.velocity
Class TurbineVelocity
java.lang.Object
|
+--org.apache.turbine.services.velocity.TurbineVelocity
- public abstract class TurbineVelocity
- 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$
- Author:
- John D. McNally, Jon S. Stevens, Jason van Zyl
Method Summary |
static org.apache.velocity.context.Context |
getContext()
This method returns a blank Context object. |
static org.apache.velocity.context.Context |
getContext(RunData data)
This returns a Context that you can pass into handleRequest
once you have populated it with information that the template
will know about. |
protected static VelocityService |
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 |
requestFinished(org.apache.velocity.context.Context context)
Performs post-request actions (releases context
tools back to the object pool). |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
TurbineVelocity
public TurbineVelocity()
getService
protected static VelocityService getService()
- Utility method for accessing the service
implementation
- Returns:
- a VelocityService 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.templateFilePath
- The path for the template files.- Returns:
- A String.
- Throws:
Exception,
- a generic exception.
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.filename
- A String with the filename of the template.out
- A OutputStream where we will write the process template as
a String.- Throws:
Exception,
- a generic exception.
getContext
public static org.apache.velocity.context.Context getContext(RunData data)
- This returns a Context that you can pass into handleRequest
once you have populated it with information that the template
will know about.
- Parameters:
data
- A Turbine RunData.- Returns:
- A Context.
getContext
public static org.apache.velocity.context.Context getContext()
- This method returns a blank Context object.
- Returns:
- A WebContext.
requestFinished
public static void requestFinished(org.apache.velocity.context.Context context)
- Performs post-request actions (releases context
tools back to the object pool).
- Parameters:
context
- a Velocity Context
Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.