Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.turbine.services.velocity
Class TurbineVelocity

    java.lang.Object
      org.apache.turbine.services.velocity.TurbineVelocity

    public abstract class TurbineVelocity

extends 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: TurbineVelocity.java 615328 2008-01-25 20:25:05Z tv $
Author:
  John D. McNally, Jon S. Stevens, Jason van Zyl, Peter Courcoux

Constructor Summary
`TurbineVelocity()`

Method Summary
`static org.apache.velocity.context.Context` | `getContext()` This method returns a blank Context object, which also contains the global context object.
`static org.apache.velocity.context.Context` | `getContext(PipelineData pipelineData)` This returns a Context that you can pass into handleRequest once you have populated it with information that the template will know about.
`static org.apache.velocity.context.Context` | `getContext(RunData data)` Deprecated. Use the PipelineData version instead.
`static org.apache.velocity.context.Context` | `getNewContext()` This method returns a new, empty Context object.
`static VelocityService` | `getService()` Utility method for accessing the service implementation
`static String` | `handleRequest(org.apache.velocity.context.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.
`static void` | `handleRequest(org.apache.velocity.context.Context context, String template, 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, String template, Writer writer)` 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, toString, wait, wait, wait`

Constructor Detail

### TurbineVelocity

    public TurbineVelocity()

Method Detail

### getService

    public static VelocityService getService()

  Utility method for accessing the service implementation

  Returns:
    a VelocityService implementation instance

### handleRequest

    public static String handleRequest(org.apache.velocity.context.Context context,
                                       String template)
                                throws 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 for the template files.
  Returns:
    A String.
  Throws:
    `Exception` - a generic exception.

### handleRequest

    public static void handleRequest(org.apache.velocity.context.Context context,
                                     String template,
                                     OutputStream out)
                              throws Exception

  Process the request and fill in the template with the values you set in the Context.

  Parameters:
    `context` - A Context.
    `template` - 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.

### handleRequest

    public static void handleRequest(org.apache.velocity.context.Context context,
                                     String template,
                                     Writer writer)
                              throws Exception

  Process the request and fill in the template with the values you set in the Context.

  Parameters:
    `context` - A Context.
    `template` - A String with the filename of the template.
    `writer` - A Writer 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)

  Deprecated. Use the PipelineData version instead.

  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(PipelineData pipelineData)

  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, which also contains the global context object. Do not use this method if you need an empty context object! Use getNewContext for this.

  Returns:
    A WebContext.

### getNewContext

    public static org.apache.velocity.context.Context getNewContext()

  This method returns a new, empty 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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2011 The Apache Software Foundation. All Rights Reserved.