1

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

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

maybe related issue logged by a4j:log:

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

Thanks!

Steve Oh
  • 1,149
  • 10
  • 18

1 Answers1

5

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

Long version:

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.

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>

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.

mabi
  • 5,279
  • 2
  • 43
  • 78
  • very helpful answer! I stay tuned ... regards – Steve Oh Feb 13 '14 at 14:12
  • I applied your trick and it seems to solve the issue... where do I have to put it ? inside form ? thx – Steve Oh Feb 13 '14 at 14:22
  • @SteveOh I've put it into my main template (the one all other pages inherit from). Since it's plain javascript, it ought to work everywhere you put it. – mabi Feb 13 '14 at 14:33