You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Werner Punz (JIRA)" <de...@myfaces.apache.org> on 2011/05/27 20:52:47 UTC

[jira] [Commented] (MYFACES-3159) ViewExpiredException occurs if you heavy use ajax within more than one form

    [ https://issues.apache.org/jira/browse/MYFACES-3159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13040382#comment-13040382 ] 

Werner Punz commented on MYFACES-3159:
--------------------------------------

Unfortunately this is not a bug, but a specification issue of JSF which hopefully will be resolved in JSF 2.2 (an error was filed on this issue for JSF 2.1 but it got postponed). I added several workarounds for this in myfaces some are part of the JSF 2.1 spec which eases it some are custom grown.

First you can add render targets in all of your forms, so that the viewstate is refreshed for every form (this is part of the JSF 2.1 spec).
It basically goes like this every form which has a render target receives a viewstate update, thats the state of jsf 2.1, still suboptimal because this adds extra work for the implementor, but if you are only on the myfaces side, I added another workaround.

I have added a myfaces custom parameter which does a simplified viewstate updating, it wont break compatibility to mojarra to add this custom parameter but it will only do something in myfaces.
Simply add following code to your page after the jsf.js include:
<script type="text/javascript">
    window.myfaces = window.myfaces || {};
      myfaces.config = myfaces.config || {};
      myfaces.config.no_portlet_env = true;
</script>

Then myfaces knows it is not in a portlet environment and will automatically update all the viewstates of all forms given in a page. 
Again sorry for having such complicated workarounds, the the issue stems from the ajax response protocol itself which does not give any indication which forms need the viewstate update, that in combination with a possible portlet environment where you can have multiple viewroots and different viewstates, makes things rather nasty in this area.


> ViewExpiredException occurs if you heavy use ajax within more than one form
> ---------------------------------------------------------------------------
>
>                 Key: MYFACES-3159
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3159
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 2.1.0
>         Environment: Java 6, Tomcat 6 and 7, latest SNAPSHOT of MyFaces 2.1.0
>            Reporter: Rene O
>         Attachments: jsf2testcase-webapp-0.0.1-SNAPSHOT.war
>
>
> I have an usecase with more than one form on a page and heavy use of ajax.
> After several ajax requests within one of the forms and after that, another ajax request in one of the other forms, a ViewExpiredException occurs.
> A simplified testcase to reproduce this issue is attached. 
> Steps to reproduce:
> 1. http://localhost:8080/jsf2testcase/test.jsf
> 2. click minimum 21 times (one more time than the default value for numberOfViewsInSession) one of the first two buttons
> 3. click the third button in the other from
> 4. ViewExpiredException occurs
> If you only use the two buttons within the first form, the ViewExpiredException never occurs, so i think this is a bug. 
> To use only one form is no option for my usecase and to increase the number of views in session is also no good solution for this, because this only delays the problem.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira