i working on gwt-ext application. in application managed client side session. write below code:
to manage session: import com.google.gwt.user.client.timer;
public class clienttimers { private static final timer session_may_have_expired_timer = new timer() { @override public void run() { // warn user, session may have expired. // show login dialog, etc... } }; public static void renewsessiontimer() { // first cancel previous timer session_may_have_expired_timer.cancel(); // schedule again in 5 minutes (maybe make configurable?) // actually, let's subtract 10 seconds that, because our timer // won't synchronized server's timer. session_may_have_expired_timer.schedule(5 * 60 * 1000 - 10000); } }
to user activity:
ext.get("pagepanel").addlistener("click", new eventcallback() { @override public void execute(eventobject e) { //messagebox.alert("on mouse click"); }); ext.get("pagepanel").addlistener("keydown", new eventcallback() { @override public void execute(eventobject e) { // //messagebox.alert("on key press click"); } });
this code working fine issues : code log out automatically time out occurs.for code want on click or key down should logout. case this:if user logged in , time log out 5 min.user don't activity on screen right per above code log out automatically 5 min complete.
now requirement if user logged in , doesn't thing 5 mins.it should not logged out automatically.instead of logging out on completion of 5 min,if user click or key down on 6 min should log out process.
basically log out process timer exceed specified time should done on user activity, not automatically.
in timer, increment variable each second. , when user click on button after 5 minutes or on 6th minute check counter variable , if variable greater 6 can use window.location.reload(); logout or reload().
Comments
Post a Comment