1
votes

How can I disallow Mojarra, injecting a javax.faces.ViewState hidden into my <form>s? I have a search <form method='GET'> which works first time my page is loaded (because my view-scoped bean is re-initialized correctly). But after an AJAX pagination in the page (over a PrimeFaces grid), Mojarra (or PrimeFaces?) injects a hidden javax.faces.ViewState into my form. Now when I submit the form it doesn't restart my view-scope bean because of javax.faces.ViewState input.

The issue here is: I want my search bean to initialize and show results to the user, but as ViewScope parameter is passed, neither this bean is initialized nor related page is shown. It just remains on the previous page.

1

1 Answers

2
votes

It's not Mojarra who's doing that, it's PrimeFaces who's doing that. Try invoking a <h:commandButton> with <f:ajax> and you'll see that it only updates the view state of the form where the button originally resides in.

You may want to report an issue to the PrimeFaces guys that they should during ajax updates not touch any <form> elements which have a method="get" and/or do not have an <input type="hidden" name="formId" value="formId">.

Until they get it fixed, your best bet is to remove the element on submit of the plain HTML form.

<form onsubmit="form.removeChild(document.getElementById('javax.faces.ViewState'))">