本文介绍了我可以从带有Richfaces的a4j:ajax的omnifaces中使用FixViewState.js(RF4 + JSF2.2/mojarra)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用出色的omnifaces 1.7解决方法 FixViewState 来解决以下问题:viewstate和ViewScope在 ajax render ="@ form" 上丢失.该解决方法似乎可以在 f:ajax 上正常工作,但不能与 a4j:ajax (richfaces)一起工作.

I use the great omnifaces 1.7 workaround FixViewState in order to fix the following issue: viewstate and ViewScope gets lost on ajax render="@form".The workaround seems to work fine with f:ajax but not with a4j:ajax (richfaces).

该修复程序是否应该可以立即与Richfaces一起使用? (richfaces版本为4.3.5)

Is the fix supposed to work with richfaces out-of-the-box? (richfaces version is 4.3.5)

可能是a4j:log记录的相关问题:

maybe related issue logged by a4j:log:

error[15:09:31.667]: [status=200] During update: javax.faces.ViewState not found

谢谢!

推荐答案

Tl; dnr:Richfaces-4.x已被JSF-2.2破坏

Tl;dnr: Richfaces-4.x is broken with JSF-2.2

长版:

关于评论和个人经验中的信息:这是Richfaces-4.x和Mojarra-2.2.x一起的已知错误.有关详细信息,请参见 RF-13317 .

With regard to information from comments and from personal experience: this is a known bug with Richfaces-4.x in conjunction with Mojarra-2.2.x. See RF-13317 for the details.

要点是JSF-2.2已更改为ViewState隐藏输入字段的规范,并且RichFaces未能跟上(它针对JSF-2.1,所以很好).它仍然呈现一个使Mojarra-2.2.x中包含的Javascript混乱的JSF-2.1视图状态ID,因为它现在试图查找具有JSF-2.1视图状态ID的元素,但找不到任何元素.这使RichFaces的每个ajax调用都名义上失败了,尽管是非破坏性的方式.

The gist is that JSF-2.2 changed to spec for the ViewState hidden input field and RichFaces hasn't kept up (it targets JSF-2.1, so that's fine). It still renders a JSF-2.1 viewstate id that confuses the Javascript included in Mojarra-2.2.x in that it now tries to find an element that has the JSF-2.1 viewstate id, but finds none. This makes every ajax call with RichFaces nominally fail, albeit in a non-destructive manner.

我个人使用一个很丑陋的技巧来完成上述步骤:

Personally, I use a rather ugly trick to make the above pass:

<o:onloadScript>
    jQuery('#viewStateContainer').html('<span id="javax.faces.ViewState"></span>');
</o:onloadScript>
<span id="viewStateContainer" style="display:none;"></span>

这为RichFaces提供了一个伪元素来放入视图状态(在处理过程中将其销毁,因此需要由onloadScript重新创建).

This provides RichFaces with a fake element to put the viewstate into (destroying it in the process, so it needs to be re-created by onloadScript).

这似乎解决了我的问题,但令人困惑.因此,您可以对此发表评论/询问.

This seems to solve my problems, but is rather confusing. So feel free to comment/ask about that.

这篇关于我可以从带有Richfaces的a4j:ajax的omnifaces中使用FixViewState.js(RF4 + JSF2.2/mojarra)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 03:57