Wicket user inactivity detection

Does anyone have an idea on how I can do this using Wicket?

I want to automatically display the Wicket announcement window when no user activity has been detected for a certain amount of time. I'm thinking about using AjaxSelfUpdatingBehavior in some way, but I don't really have any clear ideas.

Is this possible with Wicket?

+3


source to share


2 answers


Also, you can use some js library to avoid intercepting all ajax calls and make sure your user is really afflicted (doesn't even touch it with the mouse).

For example see this free framework and demo .

And (if you are using this js framework) in the gateway you have to handle



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

      

You must set $ {callbackUrl} from the gate so that js knows what action to take in the Java code. It is not difficult to do this. Take a look here .

This approach is more complicated, but if you implement it, you don't need to worry about user actions at all (it can read site information and not click on any ajax links, but suddenly it sees a modal).

+1


source


Yes, I can use this as an autologout function

public class MyTimer extends AbstractAjaxTimerBehavior {

    public MyTimer(int seconds) {
        this(Duration.seconds(seconds));
    }

    @Override
    protected void onTimer(AjaxRequestTarget target) {
         // show your window magic
    }
}

      



Add this to your page ( add(new MyTimer(300));

) and this will be called after the number of seconds you specified. Make sure to replace the timer with a new one when making ajax or reset calls.

+1


source







All Articles