I want to use Facelets to build a static HTML prototype. This prototype will be sent out to people who do not have a running web application server such as Tomcat. Is there some way to compile a Facelets site at build-time (using Ant etc) into a set of flat HTML files?
In the simplest case we have two facelets like this:
<!-- layoutFacelet.xhtml -->
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:insert name="content" />
</ui:composition>
<!-- implementationFacelet.xhtml -->
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="layoutFacelet.xhtml">
<ui:define name="content">
HELLO WORLD
</ui:define>
</ui:composition>
The output would be a single html (e.g. "implementationFacelet.output.html") like:
HELLO WORLD
In other words, Facelets is running at build-time rather than render-time, in order to produce static flat-file prototypes.
I'm not sure about any ready to use solution for your problem. However I have a rather good idea how it could be implemented thanks to working on a build-time JSF EL validator, where I'm currently adding support for facelets. I'd do this:
So this is feasible but perhaps too much work for somebody who hasn't been working with these things before. Once I'm done with my Facelets support, I'll consider adding such functionality to the validator as it would be quite easy for me then.
Best regards, Jakub