Is Facelets page generated to Servlet as JSP generated to Servlet
Asked Answered
S

2

7

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.

Sycamore answered 1/11, 2012 at 8:43 Comment(0)
L
13

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:

Lolland answered 1/11, 2012 at 11:31 Comment(0)
T
1

Not exactly the same way, it gets cached. But it doesn't generate servlet code.

Tumular answered 1/11, 2012 at 9:37 Comment(1)
Can you please, tell me the java code for this xhtml tag <f:verbatim escape="false"> <br /> </f:verbatim>Sycamore

© 2022 - 2024 — McMap. All rights reserved.