Is Facelets page generated to Servlet as JSP generated to Servlet

No, Facelets files are parsed to a XML tree using a SAX parser. The XML tree is stored in the Facelet cache. The XML tree is during view build time turned into an UIComponent tree which is accessible by FacesContext#getViewRoot() (which you can traverse by getChildren() during runtime). The component tree normally generates HTML code by their own encodeXxx() methods or the ones on the associated Renderer, starting with UIViewRoot#encodeAll().

Facelets files do not generate any class files. The XML trees are by default stored in server’s memory. Since JSF 2.1 you can however specify a custom FaceletCache implementation by <facelet-cache-factory> in faces-config.xml wherein you can write code to store the XML tree on for example the disk file system (which would be slower, though).

If you use <ui:debug> in the view and open it, then you can see the textual representation of the component tree behind UIViewRoot. See also how to debug JSF/EL

See also:

Leave a Comment