开发者

ViewExpiredException in JSF [duplicate]

This question already has answers here: javax.faces.application.ViewExpiredException: View could not be restored (11 answers) Closed 6 years ago.

I am using JSF and have javax.faces.STATE_SAVING_METHOD to client in web.xml. What I want to happen is, when session times out and I try to redirect to another page, it must redirect to sessionTimeout.jsf and on click of a button on that pa开发者_如何学Goge, it must redirect to login.jsf. I have designed sessionTimeout.jsf. Whenever session expires and I try to navigate to a different page, javax.faces.application.ViewExpiredException is thrown. I have set a session variable in target page so that everytime it goes to that page, it first checks the variable but here its throwing exception before going to that page. How to solve this ?


This could help


"Whenever session expires and I try to navigate to a different page, javax.faces.application.ViewExpiredException is thrown."

You should make pages such as error pages and the login page transient, so that the session can be invalidated when navigating away from in-session pages. Thanks to BalusC for the article on this:

http://balusc.omnifaces.org/2013/02/stateless-jsf.html

This will ensure your Session scoped beans don't get re-initialized immediately when invalidating the session in an action method, and redirecting to a view that isn't protected by your session authorization filter.


The solution is to add:

<a4j:region>
 <script language="javascript">
 A4J.AJAX.onExpired = function(loc, expiredMsg){
  window.location = "/sessionTimeOut.jsf";
 }
 </script>
</a4j:region>

Read more in RichFaces guide


add to Web.xml give message in page for reloading...

<error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>viewExpired.xhtml</location>
</error-page>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜