org.apache.velocity
public class Template extends Resource
Template template = Velocity.getTemplate("test.wm"); Context context = new VelocityContext(); context.put("foo", "bar"); context.put("customer", new Customer()); template.merge(context, writer);
Modifier and Type | Field and Description |
---|---|
private java.lang.Exception |
errorCondition |
private boolean |
initialized
To keep track of whether this template has been
initialized.
|
data, encoding, lastModified, MILLIS_PER_SECOND, modificationCheckInterval, name, nextCheck, resourceLoader, rsvc
Constructor and Description |
---|
Template()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
void |
initDocument()
initializes the document.
|
void |
merge(Context context,
java.io.Writer writer)
The AST node structure is merged with the
context to produce the final output.
|
boolean |
process()
gets the named resource as a stream, parses and inits
|
getData, getEncoding, getLastModified, getName, getResourceLoader, isSourceModified, requiresChecking, setData, setEncoding, setLastModified, setModificationCheckInterval, setName, setResourceLoader, setRuntimeServices, touch
private boolean initialized
private java.lang.Exception errorCondition
public boolean process() throws ResourceNotFoundException, ParseErrorException, java.lang.Exception
process
in class Resource
ResourceNotFoundException
- if template not found
from any available source.ParseErrorException
- if template cannot be parsed due
to syntax (or other) error.java.lang.Exception
- some other problem, should only be from
initialization of the template AST.public void initDocument() throws java.lang.Exception
java.lang.Exception
public void merge(Context context, java.io.Writer writer) throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, java.lang.Exception
context
- Conext with data elements accessed by templatewriter
- output writer for rendered templateResourceNotFoundException
- if template not found
from any available source.ParseErrorException
- if template cannot be parsed due
to syntax (or other) error.java.lang.Exception
- anything else.MethodInvocationException
Copyright ? 2002 Apache Software Foundation. All Rights Reserved.