Hello Bruno ,

Try this solution if you prefer:

public class UserIdleTimeOutControl {

        Timer mInactivityTimer;
        HandlerRegistration mHandlerRegistration;
        int mTimeoutInMillis = 5*60000;//thirty minutes max user inactivity

        public UserIdleTimeOutControl() {

            mInactivityTimer = new Timer() {
                @Override
                public void run() {
                    // Logout
                    mHandlerRegistration.removeHandler();
                    mInactivityTimer.cancel();
                    LoginServiceAsync service =
GWT.create(LoginService.class);
                    service.logout(new AsyncCallback<Void>() {
                        @Override
                        public void onFailure(Throwable caught) {
                            LogUtils.error(caught.getMessage());
                            LogUtils.loggingOut();
                        }

                        @Override
                        public void onSuccess(Void result) {
                            LogUtils.info("User idle for "+
(mTimeoutInMillis/1000)/60 +" minutes" +
                                    " logout occur : " + new Date());
                            LogUtils.loggingOut();
                        }
                    });

                }
            };
            mInactivityTimer.schedule(mTimeoutInMillis);

            NativePreviewHandler handler;
            handler = new NativePreviewHandler() {
                @Override
                public void onPreviewNativeEvent(NativePreviewEvent event) {
                    mInactivityTimer.schedule(mTimeoutInMillis);
//                    LogUtils.info("User Event fired occur: " + new
Date());

                }
            };
            mHandlerRegistration = Event.addNativePreviewHandler(handler);
        }
    }

The interface is being monitored after login, if no events occurs for the
time of 30 minutes, in this case.
the logout will be called and then redirected to login page.

It works very fine! :)

Hope it helps you,

Bruno Lopes

On Thu, Jul 1, 2010 at 4:31 PM, Bruno Santos <[email protected]> wrote:

> I would like to use the filter to do a refresh on the page so that if
> the system is idle for a period of time he returns to login screen, I
> wonder how I can do this, I tried to use the jsni:
>
> public class Filtro implements Filter {
>        public void destroy() {
>
>        }
>
>        public void doFilter(ServletRequest request, ServletResponse
> reponse,
> FilterChain chain) throws IOException, ServletException {
>
>  if((Integer)((HttpServletRequest)request).getSession().getAttribute("code")
> == null) {
>                        reload();
>                }
>                chain.doFilter(request, reponse);
>        }
>
>        public void init(FilterConfig config) throws ServletException {
>
>        }
>
>        public static native void reload() /*-{
>                $wnd.location.reload();
>        }-*/;
> }
>
> If someone knows any other solution is welcome.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-web-toolkit%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to