How can I set the view timeout?

2019-01-25 09:58发布

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?

1条回答
Juvenile、少年°
2楼-- · 2019-01-25 10:55

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:

查看更多
登录 后发表回答