velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Moshe Sambol <mos...@businesslayers.co.il>
Subject RE: Template from String
Date Thu, 15 May 2003 07:40:15 GMT
Matthew,

Loading your templates from a file is just one available option.  
You might be interested in 
org.apache.velocity.runtime.resource.loader.DataSourceResourceLoader
which you can use to load your templates from your database.

Just beware that if you choose to use it, it's doesn't come compiled in the
prebuild jars, you need to do your own "J2EE build".  There are
straightforward directions on how to do this in the readme files that
accompany Velocity.

If you're not interested in using DataSourceResourceLoader and want to stick
with your own mechanism for reading your database contents, you could create
a custom subclass of ResourceLoader.  It seems to me that such a subclass
would be very straightforward - just override getResourceStream to return a
java.io.StringBufferInputStream wrapped around the String which you've
fetched from your database, and provide basic no-op implementations of the
other methods.

Good luck.
-Moshe

> -----Original Message-----
> From: Matthew Pomar [mailto:matthewpomar@hotmail.com] 
> Sent: Thursday, May 15, 2003 4:15 AM
> To: velocity-user@jakarta.apache.org
> Subject: Template from String
> 
> 
> I have a database of email messages that are to be used as 
> templates with 
> Velocity. The examples assume templates will be files 
> (template.vm). I will 
> be getting the templates as java.lang.String objects. Could 
> someone tell me 
> how to load a template from a String rather than a file?
> 
> Thanks,
> Matthew Pomar

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message