Thinking about html e-mails for our e-commerce site I thought about reusing jsf and other 3rd party libraries as a template engine to create the e-mails on our application server (Glassfish 3, EAR).
Is it possible to manually run jsf with a local file and initialize the necessary bean to capture the html output to be saved in a String?
Why have a look at other template frameworks if jsf provides much flexibility and could do the job.
I am currently using JSF on glassfish for generating emails inside of a EJB. I based my work on the following blog post:
Basically it works when the JSF is rendered in a request that was made from the web.
I currently try to also use JSF in unit tests and scheduled executions but I currently have trouble to start JSF.
The following class is doing the initialization of Faces:
Unfortunately it requires a complete implementation of the Servlet 3.0 implementation. In my cases starting the servlet engine also requires an JMX server.
From my current experience I would recommend to use a template engine with less dependencies e.g.