Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set the view timeout?

In our JSF2 project on JBoss 7.1.1, we define a session timeout in the web.xml and it works just fine.

However, sometimes we're getting view expiration, leading to errors like this one even if the session is still alive:

javax.faces.application.ViewExpiredException: viewId:/... - View /... could 
not be restored.

Where can we set the view timeout, like we did for sessions? Or is the view expiration caused by something else?

like image 589
Xavier Portebois Avatar asked Sep 24 '12 09:09

Xavier Portebois


1 Answers

Another cause of ViewExpiredException is that too many logical views are been created in the session. The default limit is JSF implementation specific and every synchronous GET request on a particular view basically creates a new view. So, for example, when you use Mojarra (which has a default limit of 15) and start a browser session and open the same view in 16 different tabs and then submit a form in the 1st one, then you may get this exception as well. The limit is configureable with a JSF implementation specific context parameter, which is com.sun.faces.numberOfLogicalViews for Mojarra and org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION in MyFaces (defaults to 20).

This is however a very rare real world problem. If your webapp is really designed to be used this way (e.g. a social/community site which invites to being opened in multiple tabs, such as discussion forum or Q&A), then you might consider using client side state saving instead.

See also:

  • javax.faces.application.ViewExpiredException: View could not be restored
  • com.sun.faces.numberOfViewsInSession vs com.sun.faces.numberOfLogicalViews
like image 89
BalusC Avatar answered Nov 06 '22 06:11

BalusC