On 18 juil, 22:26, ccg123 <[email protected]> wrote:
> I have the following code:
>
> public class AlertEntryPoint implements EntryPoint {
>
>         static class AlertTimer extends Timer {
>                 AlertEntryPoint entryPoint = null;
>                 public AlertTimer(AlertEntryPoint alertEntryPoint) {
>                         entryPoint = alertEntryPoint;
>                 }
>
>                 @Override
>                 public void run() {
>                                 scheduleRepeating(1000 * 5 * 60);

Each time the timer runs, it will re-schedule itself repeatedly every
5mins. Fortunately, re-scheduling a timer first cancels it!

>                                 entryPoint.refreshData(this);
>                 }
>
>         }
>
>         @Override
>         public void onModuleLoad() {
>                 AlertEntryPoint.AlertTimer timer = new AlertTimer(this);
>                 timer.run();
>         }
>
>         void refreshData(final AlertTimer timer) {
>                 GwtAlertServicesDelegate.getService().getLocationNotMapped(
> ...
>
> Unfortunately, the timer is reset because the onModuleLoad() is called
> each time a page loads. I want the timer to be created once, when the
> user logs into the application -- where else can I instantiate the
> timer?

Nowhere. There's just no way to (cross-browser) have some JS code
overlap multiple web pages. Well, there's actually 2:
 - a WebWorker, but only the most recent versions of browsers (except
IE) support it
 - using frames, so you have pages with lifetime independent of each
others.
But really, this is a design issue in your code!
And why scheduling the timer 5 mins from the page load wouldn't work?

-- 
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