As all JSPs are generated / translated to Servlets before their execution, is its true for Facelets too?
I am working with JSF 2.0 and Facelets and wanted to see its generated Java Code which might be Servlet.
As all JSPs are generated / translated to Servlets before their execution, is its true for Facelets too?
I am working with JSF 2.0 and Facelets and wanted to see its generated Java Code which might be 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
Not exactly the same way, it gets cached. But it doesn't generate servlet code.
© 2022 - 2024 — McMap. All rights reserved.