Hi!
What is the right way to initialize Velocity outside
of a servlet? My application works fine when I'm using
VelocityViewServlet, but when I'm trying to initialize
Velocity from any standard Java class (with
Velocity.init(absolutePathToPropertiesFile))
Velocity.mergeTemplate always throws
Hello Leo,
For starters, try and initialize velocity with a Properties object loaded
using a Resource. Make sure that velocity.properties is in the classpath.
e.g.
InputStream vProps =
this.getClass().getResourceAsStream(/velocity.properties);
try {
Properties
what version of VelocityTools are you using? and are you trying to
initialize the Velocity singleton within the same application as the
VelocityViewServlet?
have you tried initializing a VelocityEngine instead of the singleton?
On 6/27/05, Leo Asanov [EMAIL PROTECTED] wrote:
Hi!
What is the
Hello,
Is it possible to create a Template from a String? I couldn't find an
obvious way to do this from the javadoc and wanted to ask before diving
into the source code.
Thanks.
michael
-
To unsubscribe, e-mail: [EMAIL
Michael,
Here's how I do it:
import org.apache.velocity.*;
import org.apache.velocity.runtime.parser.*;
import org.apache.velocity.runtime.*;
import org.apache.velocity.exception.*;
import java.io.*;
public class StringTemplate extends Template {
protected String _source;
public
It's even easier than that. Use the method VelocityEngine.evaluate() and
pass in a StringWriter.
http://jakarta.apache.org/velocity/api/index.html
Note that this doesn't take advantage of Velocity's extensive caching
capababilities - it's best suited for low-volume evaluation.
WILL
-
I wish it was that easy. Micheal asked how to create a Template from a String,
but VelocityEngine.evaluate() does not return a Template. Maybe that's what he
really wanted, but that's not what he asked for.
didge
Velocity Users List velocity-user@jakarta.apache.org wrote:
It's even