Also, here is my GenericEvent. public class SelectEntitiesEvent<T extends AbstractEntity> extends GwtEvent<SelectEntitiesEvent.Handler<T>> {
public interface Handler<T extends AbstractEntity> extends EventHandler { public void onSelectEntities(SelectEntitiesEvent<T> event); } public static Type<Handler<?>> TYPE = new Type<Handler<?>>(); public static HandlerRegistration register(Handler<?> handler) { return EventBusInstance.getInstance().addHandler(TYPE, handler); } private AsyncCallback<List<T>> fCallback; public SelectEntitiesEvent(AsyncCallback<List<T>> callback) { assert (callback != null); fCallback = callback; } public final AsyncCallback<List<T>> getCallback() { return fCallback; } @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public Type<Handler<T>> getAssociatedType() { return (Type) TYPE; } @Override protected void dispatch(Handler<T> handler) { handler.onSelectEntities(this); } } On Feb 22, 1:44 am, Ben Imp <benlee...@gmail.com> wrote: > After re-reading your post, I think I see the issue. While you didn't > post code for the three derived entities, I assume you are using > different type parameters for your SelectEntitiesEvent, and relying on > that to keep the events distinct. I do not believe that works either > in Java or in the translated JavaScript. As you mention, generics in > Java work on erasure, which means they don't really exist at runtime. > You would have to make them separate classes in order for the event > bus to treat them as distinct. > > http://en.wikipedia.org/wiki/Generics_in_Java#Type_erasure > > -Ben > > On Feb 21, 2:29 pm, Ben Imp <benlee...@gmail.com> wrote: > > > > > > > > > It seems like you are using a singleton event bus. I would assume all > > three entities are registered with that bus to handle the > > SelectEntitiesEvent. If thats the case, then I don't see why all > > three wouldn't have their listeners triggered. The event they > > registered for did get fired. > > > -Ben > > > On Feb 21, 12:52 pm, Riyaz Mansoor <riyaz.mans...@gmail.com> wrote: > > > > Use case: > > > > Register an event (2nd snippet) using extending classes AEntity, > > > BEntity, CEntity > > > Refresh a specific table -> create one event and fire it (1st snippet) > > > ===> the three handlers of AEntity, BEntity, CEntity are fired. Why ? > > > Expected Case: If BEntity is refreshed -> only BEntity handler should > > > fire. > > > > CellTable refresh code: > > > > @UiHandler("fRefresh") > > > protected void refresh(ClickEvent clickEvent) { > > > MsgPopup.getInstance().msgSending(); > > > SelectEntitiesEvent<T> event = new > > > SelectEntitiesEvent<T>(new > > > GenericCallback<List<T>>() { > > > public void onSuccess(List<T> result) { > > > System.out.println(result); > > > MsgPopup.getInstance().msgLoading(); > > > fDataProvider.setList(result); > > > MsgPopup.getInstance().clearMessage(); > > > > }; > > > }); > > > EventBusInstance.getInstance().fireEvent(event); > > > } > > > > Event registering - Specific classes extend this class: > > > > SelectEntitiesEvent.register(new > > > SelectEntitiesEvent.Handler<T>() { > > > @Override > > > public void > > > onSelectEntities(SelectEntitiesEvent<T> event) { > > > > > > service.selectEntities(event.getCallback()); > > > } > > > }); -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.