myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leonardo Uribe <>
Subject Re: ViewExpiredException with multiple forms on a page and ajax calls
Date Tue, 04 Oct 2011 21:37:26 GMT

The problem is not all hidden fields containing the state are updated
after the submit. It is a known problem, see:

For more details.

Try add this after your jsf.js include:

   <script type="text/javascript">
       //fixup for an issue of the jsf2.0 and 2.1 ajax spec to deal
with multiple forms per page
       window.myfaces = window.myfaces || {};
       myfaces.config = myfaces.config || {};
       myfaces.config.no_portlet_env = true;

That should work. Note
org.apache.myfaces.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION is used when
you have a multi-window app, to prevent one window swallow all slots
in session and prevent the other window to throw ViewExpiredException.
So if you set this to 2, there will be only 2 slots per window. Since
not all javax.faces.ViewState hidden fields are updated, the state
manager cannot restore the state because that view was already purged
from session map.


Leonardo Uribe

2011/10/4 Scott O'Bryan <>:
> Nope..  The higher the number the longer it will take tp expire.
> Picture this.  Each form has a view state.  Durring a PPR, the view
> state is altered for the form your submitting, but not for the other
> one.  When that form is submitted, the page thinks you're using a form
> from a long time back.  Picture someone hitting the back button 20
> times and the. Resubmitting a form..
> Generally it's considered bad form JSF, especially one involving
> AJAX, to have multiple forms.
> Scott
> Sent from my iPhone
> On Oct 4, 2011, at 4:40 AM, Francois Grandjean <> wrote:
>> Hi,
>> I'm using MyFaces 2.1.3. and I face a problem when using two forms on the same page,
one of them being refreshed several times through ajax calls before a commandLink is called
on the other form.
>> This results in a ViewExpiredException being thrown.
>> Here's a simple page to reproduce the problem:
>> <h:form id="form1">
>> <h:commandLink id="link1" value="Submit form 1">
>> <f:ajax/>
>> </h:commandLink>
>> </h:form>
>> <h:form id="form2">
>> <h:commandLink id="link2" value="Submit form 2"/>
>> </h:form>
>> If I click on link1 more than 20 (or the value of 'org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION')
times and then click on link2 I get a ViewExpiredException.
>> This looks similar to the problem depicted in MYFACES-3117, so I tried to use parameter
'org.apache.myfaces.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION' and set it to a lower value, say
>> But then I get the ViewExpiredException even quicker, after just two clicks on link1.
>> Is there something I'm doing wrong here or is this a bug or a limitation of the specs?
>> And is there any other workaround than increasing the value of org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION
or trying to replace my h:commandLink's by h:outputLink or h:link's ?
>> Thanks for your help!
>> Francois

View raw message