Thank you. I changed it and now it occurs every 5 secs as expected. I
have a question concerning calling this inner class from another
component. So now the inner class looks like this:
.
.
.
static class AlertTimer extends Timer {
AlertEntryPoint entryPoint = null;
public AlertTimer(AlertEntryPoint alertEntryPoint) {
entryPoint = alertEntryPoint;
}
@Override
public void run() {
scheduleRepeating(1000 * 5);
entryPoint.refreshData();
}
}
@Override
public void onModuleLoad() {
AlertEntryPoint.AlertTimer timer = new AlertTimer(this);
timer.run();
}
.
.
.
And from another component I want to cancel the scheduler. How do I
get a handle on the instance of AlertTimer in the code below?
public class ImageButton extends PushButton {
.
.
.
public ImageButton(Image image) {
super(image);
}
void addDialogBox(Map data, int groupType){
listener = new ClickListener() {
public void onClick(Widget sender) {
dialogbox.hide();
//start the timer again - how do i get the
instance of AlertTimer?
??????????????????????????
}
};
On Jul 8, 4:24 pm, Jaroslav Záruba <[email protected]> wrote:
> Are you sure this is what you want?
>
> while(!stop)
> {
> // without the alert all this stuff happens bazillion times each second
> schedule(1000*10);
> entryPoint.refreshData();
>
> }
>
> I'm not sure whether Timer likes to get scheduled again before it reached
> its first timeout.
> Also it looks like you might be interested in Timer.scheduleRepeating()
> and Timer.cancel();
>
> On Fri, Jul 9, 2010 at 12:52 AM, ccg123 <[email protected]> wrote:
> > Why does the timer below get triggered every second, popping up the
> > alert and crashing the browser? I expect it to be triggered every 10
> > seconds:
>
> > public class AlertEntryPoint implements EntryPoint {
>
> > Map<Integer, List<AlertDTO>> alertGroupByTypeDTOs = new
> > TreeMap<Integer, List<AlertDTO>>();
> > List locationsInfoDTOList = new ArrayList<LocationsInfoDTO>();
>
> > static class AlertTimer extends Timer {
> > AlertEntryPoint entryPoint = null;
> > public AlertTimer(AlertEntryPoint alertEntryPoint) {
> > entryPoint = alertEntryPoint;
> > }
>
> > boolean stop;
> > �...@override
> > public void run() {
> > while (!stop) {
> > schedule(1000 * 10);
>
> > entryPoint.refreshData();
>
> > Window.alert("Somebody started me");
> > }
>
> > }
>
> > }
>
> > �...@override
> > public void onModuleLoad() {
> > //refreshData();
>
> > AlertEntryPoint.AlertTimer timer = new AlertTimer(this);
> > timer.run();
> > }
> > .
> > .
> > .
>
> > --
> > 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.