Tuesday, June 4, 2013

Pb with activity and events (using gin)

Hi all,

i'm facing a litlle problem using places activities and events... Have tried multiple tricks but not luck .

My problem:
i try to fire an event from the activity but my widget does not catch it since its not loaded (I mean that if i fire this event once the widget's loaded everything works fine).

Here is my Gin configuration:

@Override
protected void configure()
{
   bind(EventBus.class).to(SimpleEventBus.class).asEagerSingleton();
   bind(PlaceHistoryMapper.class).to(MyPlaceHistoryMapper.class).in(Singleton.class);
   bind(ActivityMapper.class).to(MyActivityMapper.class).in(Singleton.class);
   bind(MyActivity.class);
   install(new GinFactoryModuleBuilder().build(MyActivityMapper.Factory.class));
}

@Provides
@Singleton
public PlaceController getPlaceController(EventBus eventBus)
{
   return new PlaceController(eventBus);
}

@Singleton
@Provides
public ActivityManager provideActivityManager(ActivityMapper activityMapper, EventBus eventBus)
{
   return new ActivityManager(activityMapper, eventBus);
}

in MyActivity:
@Inject
private MyWidget myWidget;
@Inject
private EventBus globalEventBus;

@Override
public void start(AcceptsOneWidget panel, EventBus eventBus)
{
   panel.setWidget(myWidget);
   MyEvent event = new MyEvent();
   event.setAction(MyEvent.Action.INIT);
   globalEventBus.fireEvent(event);
}

I also try two different ways of binding events in my widget, during onLoad and in constructor:

During onLoad:

@Inject EventBus eventBus;

@Override
protected void onLoad()
{
   handlersRegistration.add(eventBus.addHandler(MyEvent.TYPE, this));
}


In constructor:

private EventBus eventBus;

@Inject
public MyWidget(EventBus eventBus)
{
   this.eventBus = eventBus;
   // registration of handlers
   handlersRegistration = new ArrayList<HandlerRegistration>();
   // register myself has a listener of different event TYPE
   handlersRegistration.add(eventBus.addHandler(MyEvent.TYPE, this));
   
   ...
}


Am I doing something w rong or missing something?

Thks in advance

Tugdual

--
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 google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
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.
 
 

No comments:

Post a Comment