org.springframework.ui.velocity
Class VelocityEngineUtils

java.lang.Object
  extended by org.springframework.ui.velocity.VelocityEngineUtils

public abstract class VelocityEngineUtils
extends java.lang.Object

Utility class for working with a VelocityEngine. Provides convenience methods to merge a Velocity template with a model.

Since:
22.01.2004
Author:
Juergen Hoeller

Field Summary
private static Log logger
           
 
Constructor Summary
VelocityEngineUtils()
           
 
Method Summary
static void mergeTemplate(VelocityEngine velocityEngine, java.lang.String templateLocation, java.util.Map model, java.io.Writer writer)
          Merge the specified Velocity template with the given model and write the result to the given Writer.
static void mergeTemplate(VelocityEngine velocityEngine, java.lang.String templateLocation, java.lang.String encoding, java.util.Map model, java.io.Writer writer)
          Merge the specified Velocity template with the given model and write the result to the given Writer.
static java.lang.String mergeTemplateIntoString(VelocityEngine velocityEngine, java.lang.String templateLocation, java.util.Map model)
          Merge the specified Velocity template with the given model into a String.
static java.lang.String mergeTemplateIntoString(VelocityEngine velocityEngine, java.lang.String templateLocation, java.lang.String encoding, java.util.Map model)
          Merge the specified Velocity template with the given model into a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final Log logger
Constructor Detail

VelocityEngineUtils

public VelocityEngineUtils()
Method Detail

mergeTemplate

public static void mergeTemplate(VelocityEngine velocityEngine,
                                 java.lang.String templateLocation,
                                 java.util.Map model,
                                 java.io.Writer writer)
                          throws VelocityException
Merge the specified Velocity template with the given model and write the result to the given Writer.

Parameters:
velocityEngine - VelocityEngine to work with
templateLocation - the location of template, relative to Velocity's resource loader path
model - the Map that contains model names as keys and model objects as values
writer - the Writer to write the result to
Throws:
VelocityException - if the template wasn't found or rendering failed

mergeTemplate

public static void mergeTemplate(VelocityEngine velocityEngine,
                                 java.lang.String templateLocation,
                                 java.lang.String encoding,
                                 java.util.Map model,
                                 java.io.Writer writer)
                          throws VelocityException
Merge the specified Velocity template with the given model and write the result to the given Writer.

Parameters:
velocityEngine - VelocityEngine to work with
templateLocation - the location of template, relative to Velocity's resource loader path
encoding - the encoding of the template file
model - the Map that contains model names as keys and model objects as values
writer - the Writer to write the result to
Throws:
VelocityException - if the template wasn't found or rendering failed

mergeTemplateIntoString

public static java.lang.String mergeTemplateIntoString(VelocityEngine velocityEngine,
                                                       java.lang.String templateLocation,
                                                       java.util.Map model)
                                                throws VelocityException
Merge the specified Velocity template with the given model into a String.

When using this method to prepare a text for a mail to be sent with Spring's mail support, consider wrapping VelocityException in MailPreparationException.

Parameters:
velocityEngine - VelocityEngine to work with
templateLocation - the location of template, relative to Velocity's resource loader path
model - the Map that contains model names as keys and model objects as values
Returns:
the result as String
Throws:
VelocityException - if the template wasn't found or rendering failed
See Also:
MailPreparationException

mergeTemplateIntoString

public static java.lang.String mergeTemplateIntoString(VelocityEngine velocityEngine,
                                                       java.lang.String templateLocation,
                                                       java.lang.String encoding,
                                                       java.util.Map model)
                                                throws VelocityException
Merge the specified Velocity template with the given model into a String.

When using this method to prepare a text for a mail to be sent with Spring's mail support, consider wrapping VelocityException in MailPreparationException.

Parameters:
velocityEngine - VelocityEngine to work with
templateLocation - the location of template, relative to Velocity's resource loader path
encoding - the encoding of the template file
model - the Map that contains model names as keys and model objects as values
Returns:
the result as String
Throws:
VelocityException - if the template wasn't found or rendering failed
See Also:
MailPreparationException