为什么不对JSF页面进行预编译(至少部分),而是在每次构建视图时进行解析,评估? [英] Why not JSF pages are precompiled (atleast partially) but instead parsed, evaluated each time view is built?

查看:166
本文介绍了为什么不对JSF页面进行预编译(至少部分),而是在每次构建视图时进行解析,评估?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道这是不是真的,但我相信,我相信,JSF EL& xhtml页面不是预先编译的&只在需要时使用,但每次构建视图时都会对它们进行解析,评估和编译。

I don't know whether it is true or not but from what I've read, I believe, JSF EL & xhtml pages are not pre-compiled & just used when needed but instead they are parsed, evaluated, compiled each time the view is built.

我不明白为什么会这样做!为什么不解析&编译它只是一次,好吧至少部分,渲染一些组件可能依赖于动态获取的变量,因此它们可能会在以后呈现,但为什么延迟页面上的所有组件?无论什么样的最大值都可以预先编译和准备好使用,为什么不在部署应用程序时这样做呢?这不会改善页面的渲染时间吗?

I fail to understand why this is done so! Why not just parse & compile it just once, ok atleast partially , rendering of some components may depend on a dynamically fetched variable so they may be rendered later but why delay that for all the components on page? Whatever maximum could be pre-compiled & made ready to use, why not do it just when the application is deployed? Wont this improve rendering time of the pages ?

推荐答案

Facelets实际上能够预编译。您可以使用上下文参数 javax.faces.FACELETS_REFRESH_PERIOD 来控制Facelets刷新周期。您可以将其设置为 -1 ,以告诉JSF永远不会重新编译/重新解析Facelets文件并实际保存整个SAX编译/解析的XML树(基于缓存中的XHTML组合):

Facelets is actually capable of "precompiling". You can control the Facelets refresh period with the context parameter javax.faces.FACELETS_REFRESH_PERIOD. You can set it to -1 in order to tell JSF to never re-compile/re-parse the Facelets files and actually hold the entire SAX-compiled/parsed XML tree (based on the XHTML compositions) in cache:

<context-param>
    <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
    <param-value>-1</param-value>
</context-param>

不要在开发过程中使用此设置,或者必须在每次编辑时重新启动整个服务器一个Facelets文件。 Mojarra的默认设置为 2 (意味着缓存将每2秒刷新一次)。当 javax.faces.PROJECT_STAGE 未设置为时,MyFaces的默认设置为 -1 开发

Don't use this setting during development though, or you must restart the whole server on every edit of a Facelets file. Mojarra has a default setting of 2 (meaning, cache will be refreshed every 2 seconds). MyFaces has a default setting of -1 when javax.faces.PROJECT_STAGE is not set to Development.

如果需要,您可以通过提供自定义 FaceletsCacheFactory FaceletsCache 。请注意,这仅在JSF 2.1之后可用,因此您需要重新声明 faces-config.xml 符合JSF 2.1才能获得< ; facelet-cache-factory> 配置设置工作。

You can if necessary control the Facelets cache by providing a custom FaceletsCacheFactory and FaceletsCache. Note that this is only available since JSF 2.1 and thus you'd need to redeclare your faces-config.xml conform JSF 2.1 in order to get <facelet-cache-factory> configuration setting to work.

为了更进一步,基于XML树构建的视图(所以,整个 UIViewRoot )理论上也可以合并。 MyFaces目前已经在努力实现这一目标,另请参阅 issue 3664 。我的同事Arjan Tijms也在业余时间为Mojarra看过它。

To get a step further, the views which are built based on the XML tree (so, the entire UIViewRoot) could theoretically also be pooled. MyFaces is currently already making some effort in order to achieve this, see also issue 3664. My fellow Arjan Tijms is in his spare time also looking at it for Mojarra.

这篇关于为什么不对JSF页面进行预编译(至少部分),而是在每次构建视图时进行解析,评估?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆