| java.lang.Object org.apache.turbine.services.velocity.TurbineVelocity
TurbineVelocity | abstract public class TurbineVelocity (Code) | | 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);
author: John D. McNally author: Jon S. Stevens author: Jason van Zyl version: $Id: TurbineVelocity.java 534527 2007-05-02 16:10:59Z tv $ |
Method Summary | |
public static 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. | public static Context | getContext() This method returns a blank Context object, which
also contains the global context object. | public static Context | getNewContext() This method returns a new, empty Context object. | public static VelocityService | getService() | public static String | handleRequest(Context context, 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.
Parameters: context - A Context. Parameters: template - The path for the template files. | public static void | handleRequest(Context context, String template, OutputStream out) Process the request and fill in the template with the values
you set in the Context. | public static void | handleRequest(Context context, String template, Writer writer) Process the request and fill in the template with the values
you set in the Context. | public static void | requestFinished(Context context) Performs post-request actions (releases context
tools back to the object pool). |
getContext | public static Context getContext(RunData data)(Code) | | 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. A Context. |
getContext | public static Context getContext()(Code) | | This method returns a blank Context object, which
also contains the global context object. Do not use
this method if you need an empty context object! Use
getNewContext for this.
A WebContext. |
getNewContext | public static Context getNewContext()(Code) | | This method returns a new, empty Context object.
A WebContext. |
getService | public static VelocityService getService()(Code) | | Utility method for accessing the service
implementation
a VelocityService implementation instance |
handleRequest | public static String handleRequest(Context context, String template) throws Exception(Code) | | 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. Parameters: template - The path for the template files. A String. exception: Exception - a generic exception. |
handleRequest | public static void handleRequest(Context context, String template, OutputStream out) throws Exception(Code) | | Process the request and fill in the template with the values
you set in the Context.
Parameters: context - A Context. Parameters: template - A String with the filename of the template. Parameters: out - A OutputStream where we will write the process template asa String. exception: Exception - a generic exception. |
handleRequest | public static void handleRequest(Context context, String template, Writer writer) throws Exception(Code) | | Process the request and fill in the template with the values
you set in the Context.
Parameters: context - A Context. Parameters: template - A String with the filename of the template. Parameters: writer - A Writer where we will write the process template asa String. exception: Exception - a generic exception. |
requestFinished | public static void requestFinished(Context context)(Code) | | Performs post-request actions (releases context
tools back to the object pool).
Parameters: context - a Velocity Context |
|
|