Blapo Merjebo
Blapo Merjebo

Reputation: 21

No ajax action fired after session invalidate

We have a JSF webapp with Primefaces 4.0 and CAS Single Sign On.

When a user requests an ajax action (by clicking a p:commandButton or similar component with ajax=true) after he has lost his session because SSOut in another tab, nothing happens, no response from server or action is triggered. We need to manage that situation to inform the user that his session is no longer available, by showing a dialog or redirecting him to home or a custom page, but we don't know how.

ajax=false solves the problem, but this is not what we want to do.

No ViewExpiredException is thrown.

EDIT: We had already read and tried this BalusC's solution without success. No Exception is thrown and Handler has nothing to do. Note that isn't an Expired Session or Invalidated by TimeOut session, is just an explicit session.invalidate caused by Cas Sign Out in another tab.

We also tried javascript jsf.ajax.addOnError() solution, and again nothing to capture. Only p:ajaxStatus onError event catches something, but no way to identify that particular error. Even overriding ajaxStatus javascript function, error data parameter is undefined... Also, p:log says "Request return with error:error." but, which error is it? how do we identify it? We are stuck on this issue...

Upvotes: 2

Views: 1330

Answers (1)

Predrag Maric
Predrag Maric

Reputation: 24423

This has been discussed many times, and as far as know there aren't any out-of-the-box solutions yet. One solution is to add a custom ExceptionHandler as stated in this post.

Another option is to register client error handler using jsf.ajax.addOnError(...), and to handle this exception in it. You might need some server code to add a custom header in case session is invalid, which you would use in error handler to be able to differentiate that specific case from other errors.

Upvotes: 2

Related Questions