It's possible to use most wicket components just to generate an output. Say to generate html page for email and send via javax.mail.
It takes TemplatePage (child of wicket.Page) implementation and writes result to given java.io.Writer. All stuff like sessions, versioning, request parameters are disabled, TemplatePage is always stateless.
Yes, web page is not the same as email, but very-very close. Of course, it's nearly impossible to reuse the same WebPage, but you can reuse some your components both on WebPage and TemplatePage. And of course it's possible to use most standard wicket components like wicket:border, wicket:extend, repeaters, etc...
Yet another great benefits, but I've not done it yet:

  • it's possible to make auto-linking of resources. Say, if you have <img> on your page, the generated email will have the image attached and properly linked as "cid:" resource.
  • if you have a link in email to your web-site back, it could be properly handled and checked if it actually links to correct Page.

Draft source code is here: http://files.rsdn.ru/20380/WicketTemplater.rar

  • No labels