0

I have implemented the answer of this question: Session timeout and ViewExpiredException handling on JSF/PrimeFaces ajax request

When an AJAX request is done and there is a ViewExpiredException it renders my session expired page, which has a link to go to the login page. But when you login again it shows me this:

<partial-response id="j_id1">
    <changes>
        <update id="j_id1:javax.faces.ViewState:0">
            <![CDATA[ -4163638607746842558:-2237921975175382496 ]]>
        </update>
    </changes>
</partial-response>

When I press F5 the normal HTML content is shown. Why is this happening and how can I solve it?

Edit: To clarify, after logging in it takes me to the same page where the ViewExpiredException occurred.

Community
  • 1
  • 1
Wesley Egbertsen
  • 720
  • 1
  • 8
  • 25
  • In the answer there are several suggestions. Which one did you use? You created a custom one? Advice: don't... use the PrimeFaces one or the OmniFaces one. – Kukeltje Nov 05 '15 at 10:34
  • I used the ExceptionHandler and ExceptionHandlerFactory from JSF and used the answer from Douglas Junior as a basis. – Wesley Egbertsen Nov 05 '15 at 10:39
  • Tip: you can edit your comment within 5 minutes of posting it... – Kukeltje Nov 05 '15 at 10:43
  • Answer depends on authentication framework being used. It's just stubbornly re-executing the last remembered request which didn't pass authentication. You basically need to reconfigure it with either a fixed target or make it JSF ajax aware. – BalusC Nov 05 '15 at 10:50
  • @BalusC I use j_security_check (glassfish jdbc realm). How would I solve this with this authentication framework? – Wesley Egbertsen Nov 05 '15 at 10:53
  • Does this answer your question too? http://stackoverflow.com/questions/12504131/viewexpiredexception-not-thrown-on-ajax-request-if-jsf-page-is-protected-by-j-se/ – BalusC Nov 05 '15 at 10:54
  • I don't think so, because when I do an AJAX request when the session is expired I get the ViewExpiredException. This one is handled by my customexceptionhandler and does this: `if (t instanceof ViewExpiredException) { nav.handleNavigation(fc, null, "/session_expired.xhtml?faces-redirect=true"); }` On that page it says the session is expired and has a link that the user can click on to go to the login page, but it doesn't matter if you click the link or go yourself to the login page. After you login it shows the partial response. Or am I wrong and is that answer relevant to my question? – Wesley Egbertsen Nov 05 '15 at 11:03
  • I also find it weird that when I login it goes back to where the ViewExpiredException occurred, I diddn't specify this? – Wesley Egbertsen Nov 05 '15 at 11:04
  • @BalusC I think I solved it, I don't know if its THE solution, but I added `FacesContext.getCurrentInstance().getExternalContext().invalidateSession();` before it does the handleNavigation and now I don't get partial-response stuff anymore. – Wesley Egbertsen Nov 05 '15 at 11:15

0 Answers0