JSF和自动重载xhtml文件 [英] JSF and automatic reload of xhtml files
问题描述
我在使用JRebel,Spring,JSF Mojarra 2.0.3和WebLogic 10.3热重新加载XHTML文件方面遇到了一些问题。
I had some problems with hot-reloading XHTML files using JRebel, Spring, JSF Mojarra 2.0.3 and WebLogic 10.3.
JRebel重新加载常规Java类和js / / WebContent下的css文件成功,但不是JSF的.xhtml文件。需要完整的重新发布才能在服务器上更新xhtml文件。
JRebel reloads regular Java classes and js/css files under /WebContent successfully, but not JSF's .xhtml files. A full republish was necessary to get xhtml files updated on the server.
通过反复试验我终于通过向web.xml添加一些facelets参数并创建它来实现它一个自定义的ResourceResolver,如所述这篇博文。
By trial and error I finally got it to work by adding some facelets parameters to web.xml and creating a custom ResourceResolver as described in this blog post.
但是,我想知道为什么会这样,更具体地说:
However, I wonder WHY this works, and more specifically:
- 为什么是需要自定义ResourceResolver吗?
- 是不是JRebel应该通过监视xhtml文件所在的/ WebContent来处理这个问题?
- 我猜它与Facelets / JSF通过FacesServlet编译xhtml到servlets(?)有什么关系,JRebel无法检测到它?
推荐答案
JRebel处理/ WebContent文件夹更改。
JRebel handles /WebContent folder changes.
问题是Facelets会进行缓存而不会重新读取已更改的文件。要强制重读,请在 web.xml
中指定以下参数。
The problem is that Facelets do caching and do not reread changed files. To force reread specify the following parameters in web.xml
.
JSF 2 ( Facelets 2.x):
JSF 2 (Facelets 2.x):
<!-- Time in seconds that facelets should be checked for changes since last request. A value of -1 disables refresh checking. -->
<context-param>
<param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
<param-value>0</param-value>
</context-param>
<!-- Set the project stage to "Development", "UnitTest", "SystemTest", or "Production". -->
<!-- An optional parameter that makes troubleshooting errors much easier. -->
<!-- You should remove this context parameter before deploying to production! -->
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
JSF 1.2 (Facelets 1.x)参数是:
For JSF 1.2 (Facelets 1.x) parameters are:
<context-param>
<param-name>facelets.REFRESH_PERIOD</param-name>
<param-value>0</param-value>
</context-param>
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
有关JSF上下文参数的更多信息: http://docs.jboss.org/jbossas/6/JSF_Guide/en-US/ html / jsf.reference.html#standard.config.params
More on JSF context params: http://docs.jboss.org/jbossas/6/JSF_Guide/en-US/html/jsf.reference.html#standard.config.params
在您的情况下不需要自定义资源解析程序。资源解析器只是从自定义文件系统文件夹中获取xhtml文件的一种棘手的方法。在你的情况下,JRebel会这样做(甚至更多)。
That custom resource resolver is not needed in your case. That resource resolver is just a tricky way to get xhtml files from custom file system folder. In your case JRebel does that (and even more).
这篇关于JSF和自动重载xhtml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!