如何解决Facelets和Spring Web Flow中的刷新问题?

时间:2020-12-01 20:07:58

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).

对于我的特定项目,我使用的是Facelets(1.1.14),MyFaces(1.2.3)和Spring Web Flow(2.0.3)。我的IDE是JDeveloper 10.1.3.3。我的浏览器是IE6(工作要求)。

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.

好的......今天遇到了一个非常奇怪的问题。通常,当我使用Facelets时,我可以对xhtml文件进行任何我想要的更改,刷新浏览器窗口,并立即查看更改。我将Facelets开发设置为true,并将Facelets刷新周期设置为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.

直到今天下午,我对Facelets刷新这个项目没有任何问题。但是,就在今天下午,我开始发现当我刷新页面时没有出现对css样式和类的更改。然后我开始看到与其他页面元素类似的问题。在某些情况下,更改永远不会出现。在其他时候,我可以在一段时间后刷新页面,并且反映了更改。

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?

我的Facelets页面发生了什么变化?这就像他们已经变得粘稠了。我习惯于立即更改页面刷新而不会出现问题。有没有人遇到过这个?任何解决方案或建议?

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...

这个问题与Spring Web Flow有关。我的一个页面是纯Facelets,它立即反映了刷新的变化。我的其他xhtml页面在我的流程定义中作为视图状态被调用,并显示上述症状。不过,他们在一两天前工作正常......

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.

似乎每当我有一个facelets xhtml文件被渲染为流的视图状态并且有一个h:form元素时,当我在页面上更改JSF元素并刷新浏览器时,我会遇到奇怪的行为。这包括不显示其样式或样式类的更改。

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.

对常规HTML元素的更改(如更改输入元素的样式)似乎工作正常。将h:form更改为常规HTML表单允许立即更改页面刷新,即使在JSF元素上也是如此。当我不执行流程(仅使用Facelets)时查看页面时,即使使用h:表单,我也从未遇到任何问题。

Please tell me someone has encountered this before, and has some solution. Anyone?

请告诉我之前有人遇到过此问题,并且有一些解决方案。任何人?

2 个解决方案

#1


3  

If you have entry of facelets.REFRESH_PERIOD -1 in your web.xml , this is causing the problem. Just cross check it by removing this entry.

如果您在web.xml中输入了facelets.REFRESH_PERIOD -1,则会导致问题。只需删除此条目即可交叉检查。

#2


0  

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.

我不确定这是否适用于Web Flow,但我知道使用Spring MVC,您可以选择让控制器实现LastModified接口,这允许Spring向浏览器发送“Last-Modified”HTTP标头。

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.

Servlet通常不会设置此HTTP标头值,导致浏览器每次都请求新的文件副本,但是,如果设置了“Last-Modified”标头,浏览器知道如果没有URL则检索URL的内容自上次检索页面以来,我们一直在修改。

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.

我怀疑你的Web Flow“控制器”(原谅我滥用术语,我不熟悉Web Flow)正在设置“Last-Modified”标题,而你的常规Facelets页面却没有。

For what it's worth, I think setting Last-Modified is generally a good idea, unless your page is dynamic.

对于它的价值,我认为设置Last-Modified通常是一个好主意,除非您的页面是动态的。

#1


3  

If you have entry of facelets.REFRESH_PERIOD -1 in your web.xml , this is causing the problem. Just cross check it by removing this entry.

如果您在web.xml中输入了facelets.REFRESH_PERIOD -1,则会导致问题。只需删除此条目即可交叉检查。

#2


0  

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.

我不确定这是否适用于Web Flow,但我知道使用Spring MVC,您可以选择让控制器实现LastModified接口,这允许Spring向浏览器发送“Last-Modified”HTTP标头。

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.

Servlet通常不会设置此HTTP标头值,导致浏览器每次都请求新的文件副本,但是,如果设置了“Last-Modified”标头,浏览器知道如果没有URL则检索URL的内容自上次检索页面以来,我们一直在修改。

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.

我怀疑你的Web Flow“控制器”(原谅我滥用术语,我不熟悉Web Flow)正在设置“Last-Modified”标题,而你的常规Facelets页面却没有。

For what it's worth, I think setting Last-Modified is generally a good idea, unless your page is dynamic.

对于它的价值,我认为设置Last-Modified通常是一个好主意,除非您的页面是动态的。