We have a Wicket web app with lots of AJAX buttons that change state etc., without doing a whole of page refresh - all typical stuff.
What we've noticed is that, after the session has timed out, if on a page requiring authentication, as we have auto logon via typical session/cookie technique, the page is simply re-rendered with no feedback to the user - but the click they made has been consumed and effectively ignored.
This can be a bit disheartening at times because they can click to change the state of something or start up a process and then move to a different tab in the browser or some other app only to find out, when they return to the Wicket app, that the state is not changed or the process has not started - it is like they never clicked the button.
Is there a standard way to handle these session timeouts in regard to AJAX clicks?
I tried adding an IRequestCycleListener:
public class SessionValidator implements AbstractRequestCycleListener {
@Override
public void onRequestHandlerScheduled(RequestCycle cycle, IRequestHandler handler) {
if (handler instanceof AjaxRequestHandler) {
boolean authenticated = false;
if (Session.exists()) {
SignIn2Session session = (SignIn2Session)Session.get();
if (!session.isSessionInvalidated()) {
if (session.isSignedIn())
authenticated = true;
}
}
if (!authenticated) {
cycle.setResponsePage(SignIn2.class);
}
}
}
But by the time the AjaxRequestHandler is being notified a page rendering handler has already gone in an refreshed the session and re-authenticated the user. So the AjaxRequestHandler always sees a valid session with an authenticated user.
Any suggestions of how to give some feedback to the user rather than just effectively ignoring their click?
I've even thought off turning of auto authentication altogether and forcing users to log in again (their browser will most likely have their password stored anyway so not such a big deal)