如何解决 Facelets 和 Spring Web Flow 中的刷新问题?
对于我的特定项目,我使用 Facelets (1.1.14)、MyFaces (1.2.3) 和 Spring Web Flow (2.0.3)。 我的 IDE 是 JDeveloper 10.1.3.3。 我的浏览器是IE6(工作需要)。
好吧...今天遇到一个很奇怪的问题。 通常,当我使用 Facelets 时,我可以对 xhtml 文件进行任何我想要的更改,刷新浏览器窗口,并立即查看更改。 我已将 Facelets 开发设置为 true,并将 Facelets 刷新周期设置为 1。
截至今天下午,我在此项目上的 Facelets 刷新没有遇到任何问题。 然而,就在今天下午,我开始发现刷新页面时没有出现对 css 样式和类的更改。 然后我开始在其他页面元素上看到类似的问题。 在某些情况下,这些变化永远不会出现。 其他时候,我可以在一段时间后刷新页面,并且更改已得到反映。
我的 Facelets 页面刷新发生了什么? 就好像它们都变得粘稠了。 我习惯于在页面刷新时立即进行更改,而不会出现任何复杂情况。 以前有人遇到过这个吗? 有什么解决方案或建议吗?
编辑
这个问题与 Spring Web Flow 有关。 我的一个页面是纯 Facelets,它会立即反映刷新时的变化。 我的其他 xhtml 页面在我的流定义中被调用为视图状态,并显示上述症状。 不过,就在一两天前,它们还工作得很好...
编辑
好吧,我已经能够隔离症状,但我仍然不知道其原因。
似乎只要我有一个 Facelets xhtml 文件,该文件呈现为流的视图状态并具有 h:form 元素,那么当我更改页面上的 JSF 元素并刷新浏览器时,我就会出现奇怪的行为。 这包括不显示样式或样式类的更改。
对常规 HTML 元素的更改(例如更改输入元素的样式)似乎效果很好。 将 h:form 更改为常规 HTML 表单可以在页面刷新时立即进行更改,甚至在 JSF 元素上也是如此。 当我在不执行流程(仅使用 Facelets)时查看页面时,即使使用 h:form 也不会遇到任何问题。
请告诉我以前有人遇到过这种情况,并且有一些解决方案。 任何人?
For my particular project, I'm using Facelets (1.1.14), MyFaces (1.2.3), and Spring Web Flow (2.0.3). My IDE is JDeveloper 10.1.3.3. My browser is IE6 (work requirement).
Okay...ran into a very weird issue today. Normally, when I'm using Facelets, I can make whatever changes I want to my xhtml file, refresh my browser window, and see the changes immediately. I've got Facelets development set to true, and Facelets refresh period set to 1.
Up to this afternoon, I've had no problem with Facelets refreshes on this project. However, just this afternoon, I starting finding that changes to css styles and classes did not appear when I refreshed the page. Then I started seeing similar issues with other page elements. In some cases the changes never appear. At other times, I can refresh the page after a little while has passed and the changes have been reflected.
What happened to my Facelets page refreshes? It's like they've gone all sticky. I'm used to immediate changes on page refresh without complications. Has anyone run into this before? Any solutions or suggestions?
EDIT
The issue has something to do with Spring Web Flow. One of my pages is pure Facelets, and it's reflecting changes on refresh immediately. My other xhtml pages are invoked as view states in my flow definitions, and show the symptoms described above. Still, they were working fine just a day or two ago...
EDIT
Ok, I've been able to isolate the symptom, but I still don't know its cause.
It seems that whenever I have a facelets xhtml file that is rendered as a view-state of a flow and has an h:form element, then I get odd behavior when I make changes to the JSF elements on my page and refresh my browser. This includes not showing changes in their styles or style classes.
Changes to regular HTML elements (like changing the style of an input element) seem to work fine. Changing the h:form to a regular HTML form allow for immediate changes on page refresh, even on JSF elements. When I view the page when I'm not executing a flow (just using Facelets), then I never encounter any problems, even when using an h:form.
Please tell me someone has encountered this before, and has some solution. Anyone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的
web.xml
中有facelets.REFRESH_PERIOD -1
条目,则这会导致问题。 只需删除此条目即可进行交叉检查。If you have entry of
facelets.REFRESH_PERIOD -1
in yourweb.xml
, this is causing the problem. Just cross check it by removing this entry.我不确定这是否适用于 Web Flow,但我确实知道使用 Spring MVC,您可以选择让控制器实现 LastModified 接口,这允许 Spring 向浏览器发送“Last-Modified”HTTP 标头。
Servlet 通常不会设置此 HTTP 标头值,这会导致浏览器每次都请求文件的新副本,但是,如果设置了“Last-Modified”标头,则浏览器知道不会检索 URL 的内容(如果该 URL 没有)自上次检索页面以来未曾修改过。
我怀疑您的 Web Flow“控制器”(请原谅我滥用术语,我对 Web Flow 不熟悉)正在设置“Last-Modified”标头,而您的常规 Facelets 页面则没有。
就其价值而言,我认为设置 Last-Modified 通常是一个好主意,除非您的页面是动态的。
I'm not sure if this applies to Web Flow, but I do know that with Spring MVC, you have an option of having your controller implement the LastModified interface, which allows Spring to send the browser the "Last-Modified" HTTP header.
Servlets typically don't set this HTTP header value, causing browsers to request a new copy of the files each time, however, if the "Last-Modified" header is set, browsers know not to retrieve the contents of a URL if it hasn't been modified since the page was last retrieved.
I suspect your Web Flow "controller" (pardon my abuse of terminology, I'm not familiar with Web Flow) is setting the "Last-Modified" header, while your regular Facelets page is not.
For what it's worth, I think setting Last-Modified is generally a good idea, unless your page is dynamic.