开发者

Using seam:mail in Message Driven Bean

I'm familiar with JSF and have the requirement for automatically creating e-mails. I like the idea of seam:mail of templating e-mails in a JSF-style and also use JSF components:

<m:message>
  <m:from name="Peter" address="peter@example.com" />
  <m:to name="#{person.firstname} #{person.lastname}">#{person.address}</m:to>
  <m:subject>Try out Seam!</m:subject>
  <m:body>
    <p><h:outputText value="Dear #{person.firstname}" />,</p>
    <p>You can try out Seam by visiting 
    <a href="http://example.com">http://example.com</a>.</p>
    &l开发者_开发技巧t;p>Regards,</p>
    <p>Pete</p>
  </m:body>
</m:message>

As far as I understood the Documentation, especially this snippet (shortened),

So, now you have your email template, how do you go about sending it? Well, at the end of rendering the m:message the mailSession is called to send the email, so all you have to do is ask Seam to render the view,

@In(create=true) private Renderer renderer;

public void send()
{
   renderer.render("/simple.xhtml");
   facesMessages.add("Email sent successfully");
} 

this is invoked in a common JSF (Facelet) page. Is there any chance to do this in a Message Driven Bean? Or should I head to other templating engines? see Suggestions for Java email templating?


AFAIK Message Driven Beans are for receiving messages. I think it does not make much sence with your requirement for automatically creating e-mails.

Anyways, this Seam tutorial tells you about sending and receiving JMS messages with seam. Maybe it serves for your purpose, whatever it is.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜