是将Facelets页面生成为Servlet作为JSP生成的Servlet [英] Is Facelets page generated to Servlet as JSP generated to Servlet
问题描述
由于所有的JSP都是在执行之前生成/翻译为Servlet的,所以对于Facelets也是如此。
As all JSPs are generated / translated to Servlets before their execution, is its true for Facelets too?
我使用JSF 2.0和Facelets,它生成的Java代码可能是Servlet。
I am working with JSF 2.0 and Facelets and wanted to see its generated Java Code which might be Servlet.
推荐答案
否,Facelets文件被解析为一个XML树使用 SAX解析器。 XML树存储在 Facelet缓存。 XML树位于查看构建时间变成 UIComponent
树,可通过 FacesContext#getViewRoot()
(您可以在运行时通过 getChildren()
遍历。组件树通常通过自己的 encodeXxx()
方法或关联的 Renderer
,以 UIViewRoot#encodeAll )
。
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文件不要生成任何类文件。 XML树默认存储在服务器的内存中。自JSF 2.1起,您可以指定自定义 <$通过< facelet-cache-factory>
在 faces-config中执行
xml 其中你可以编写代码来存储XML树,例如磁盘文件系统(这将是更慢的,虽然)。
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).
您在视图中使用< ui:debug>
并打开它,然后您可以看到 UIViewRoot $后面的组件树的文本表示c $ c>。另请参见如何调试JSF / EL
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
- 视图构建时间是什么?
- 在服务器请求后测量JSF视图的渲染时间
- / a>
- Why not JSF pages are precompiled (atleast partially) but instead parsed, evaluated each time view is built?
- What's the view build time?
- Measure the render time of a JSF view after a server request
- Why Facelets is preferred over JSP as the view definition language from JSF2.0 onwards?
这篇关于是将Facelets页面生成为Servlet作为JSP生成的Servlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!