2008/8/5 Torsten Krohn <[EMAIL PROTECTED]>: > At the spring reference I found a velocity-based example to create email > content: > > http://static.springframework.org/spring/docs/2.5.x/reference/mail.html#mail-templates-example > > private void sendConfirmationEmail(final User user) { > MimeMessagePreparator preparator = new MimeMessagePreparator() { > public void prepare(MimeMessage mimeMessage) throws Exception { > MimeMessageHelper message = new MimeMessageHelper(mimeMessage); > message.setTo(user.getEmailAddress()); > message.setFrom(emailstring); > Map model = new HashMap(); > model.put("user", user); > String text = VelocityEngineUtils.mergeTemplateIntoString( > velocityEngine, "com/dns/registration-confirmation.vm", > model); > message.setText(text, true); > } > }; > this.mailSender.send(preparator); > } > > Can I do this with Apache Tiles 2. If so, how?
Mmm challenging question, and I think it means a lot of development. First of all, you have to choose your templating language. Let's suppose that you stick with velocity. You need to: - create the integration of Tiles in Velocity: in fact there is an ongoing porting made by a contributor, see: https://issues.apache.org/struts/browse/TILES-170 - you need a different application and request context. So you have to create your own implementation of TilesApplicationContext and TilesRequestContext; - you need to startup the Tiles engine, i.e. create the TilesContainer. In other words, there is a lot of stuff to do. IMHO, if you need a small amout of mail templates, I suggest other mechanisms of inclusion, for example using #include and #parse in Velocity. Ciao Antonio
