Re: Tapestry Resources and Velocity Templates
Look at setting the file.resource.loader.path property http://static.springsource.org/spring/docs/2.5.6/reference/view.html#view-velocity-advancedconfig http://static.springsource.org/spring/docs/2.5.6/reference/view.html#view-velocity-advancedconfig Andrew Jonhy Pear wrote: > > Hi! > > I have configured Spring Email to send emails to users. > > I want to use Velocity (not a requirement though, the only requirement is > to > have templating) to help me generate the body of the mail. > > I have a Tapestry service where I inject both VelocityEngine and > MailSender > services. > > Then, in the method sendRegistrationConfirmationEmail(User user) { > > ... > > String body = > VelocityEngineUtils.mergeTemplateIntoString(this.velocityEngine, > "UserRegistrationConfirm.vm", model); > > } > > I have my template UserRegistrationConfirm.vm in > src/main/resources/ under the same package as my service from where I use > velocity. > > However the template could not be found. > > I have in my applicationContext.xml the following configuration for > Velocity: > > > > class="org.springframework.ui.velocity.VelocityEngineFactoryBean"> > > > class > > > org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader > > > > > Do you have any hint on how to tell velocity to lookup in > src/main/resources/... ? > > thank you, > > -- View this message in context: http://old.nabble.com/Tapestry-Resources-and-Velocity-Templates-tp26364177p26385154.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Tapestry Resources and Velocity Templates
On Sun, Nov 15, 2009 at 2:22 PM, Jonhy Pear wrote: > I have configured Spring Email to send emails to users. Spring email buys almost nothing, if that's the only thing you use Spring for, you could just as well use Velocity and plain javamail directly (or alternatively chenillekit-mail). > class="org.springframework.ui.velocity.VelocityEngineFactoryBean"> > > > class > > > org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader > > > > Do you have any hint on how to tell velocity to lookup in > src/main/resources/... ? Reading from src/main/resources is not what you want. Maven copies files in src/main/resources to classes/, so you want read the templates from your classpath. Here's my corresponding direct Velocity configuration (which works): Velocity.setProperty(Velocity.RESOURCE_LOADER, "classpath"); Velocity.addProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName()); Velocity.init(); So I assume the problem is simply that the value of resource.loader should be "classpath", not "class". Kalle - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Tapestry Resources and Velocity Templates
Hi! I have configured Spring Email to send emails to users. I want to use Velocity (not a requirement though, the only requirement is to have templating) to help me generate the body of the mail. I have a Tapestry service where I inject both VelocityEngine and MailSender services. Then, in the method sendRegistrationConfirmationEmail(User user) { ... String body = VelocityEngineUtils.mergeTemplateIntoString(this.velocityEngine, "UserRegistrationConfirm.vm", model); } I have my template UserRegistrationConfirm.vm in src/main/resources/ under the same package as my service from where I use velocity. However the template could not be found. I have in my applicationContext.xml the following configuration for Velocity: class org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader Do you have any hint on how to tell velocity to lookup in src/main/resources/... ? thank you,