Hi,
I ran into a weird situation. In my activity's start I have the following
code at the end of the method:
public void *start*(AcceptsOneWidget containerWidget, EventBus
eventBus) {
homeView = clientFactory.getHomeView();
clientFactory.getEventBus().*addHandler*(HomeDataEvent.TYPE, new
HomeDataEventHandler(){
public void *onEvent*(HomeDataEvent event) {
logger.severe("on event "+event);
showOrders(event);
}
});
containerWidget.setWidget(homeView.asWidget());
clientFactory.getDataProvider().*getOrders*
(clientFactory.getSession().getCurrentUser());
}
Now, my MockDataProvider's getOrders() method simply fires a HomeDataEvent with
some dummy data.
public void *getOrders*(UserInfo ui) {
ArrayList<OrderInfo> oil = new ArrayList<OrderInfo>();
OrderInfo oi = new OrderInfo("123456", "[email protected]");
oil.add(oi);
HomeDataEvent hde = new HomeDataEvent();
hde.setOrders(oil);
logger.severe("got orders. firing HDE "); *//This line is printed but the
event is not received by the handler*
*cf.getEventBus().fireEvent(hde);*
}
I was expecting the EventHandler code registered in Activity's start method
to be called. But it was never called.
Then I changed the registration code to:
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand()
{
public void execute()
{
clientFactory.getDataProvider().getOrders(clientFactory.getSession().getCurrentUser());
}
});
And it worked. So basically, unless the start() method finishes, the
handler is not registered? Any idea what is happening and why it does not
work without the scheduleDeferred?
thank you,
Andy.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.