Search code examples
wicketuser-activity

Detect Wicket user inactivity


Does anybody have an idea on how I can accomplish this using Wicket?

I want to display a Wicket odal window automatically when no user activity has been detected for a certain amount of time. I'm thinking of using an AjaxSelfUpdatingBehavior in some way, but I have no clear ideas actually.

Is this possible with Wicket?


Solution

  • Also, you can use some js library not to catch all ajax calls and to be sure, that your user is really afk (even does not touching his mouse).

    For example, see this free framework and it's demo.

    And (if you using this js framework) in wicket you must handle

    ifvisible.idle(function(){
        Wicket.Ajax.get({u: '${callbackUrl}'})// This code will work when page goes into idle status
    });
    

    You must set ${callbackUrl} from wicket code to let js know what action to proceed in java code. It is not hard to do this. Look here.

    This approach is more tricky, but if you implement this, you don't have to worry about users actions at all (he can read site's info and don't click any ajax links, but suddenly he will see modal window).