title: GWT fire events
body: <p>I'm using GWT 2.4 by using the MVP pattern</p>
  
  <p>I have this situation:
  In one presenter (let's call it a TreePresenter since it shows a tree) i have the following code:</p>
  
  <pre><code>display.getSelectedItem().addSelectionHandler(new SelectionHandler&lt;TreeItem&gt;() {
  
          @Override
          public void onSelection(SelectionEvent&lt;TreeItem&gt; event) {
              ....
              evtBus.fireEvent(new SelectCategoryEvent(item.getText()));
              .....
          }
      });
  </code></pre>
  
  <p>And in my AppController class I have this situation:</p>
  
  <pre><code>        eventBus.addHandler(SelectCategoryEvent.TYPE, new SelectCategoryEventHandler() {
  
          @Override
          public void onSelectCategory(SelectCategoryEvent event) {
              saveHistoryEvent(event);
          }
      });
  </code></pre>
  
  <p>When i select one itm in the three the event is correctly fired by the instruction </p>
  
  <pre><code>evtBus.fireEvent(new SelectCategoryEvent(item.getText()));
  </code></pre>
  
  <p>But in my AppController the event is not propagated and I can't handle it in the code </p>
  
  <pre><code>        eventBus.addHandler(SelectCategoryEvent.TYPE, new SelectCategoryEventHandler() {
  
          @Override
          public void onSelectCategory(SelectCategoryEvent event) {
              saveHistoryEvent(event);
          }
      });
  </code></pre>
  
  <p>Can anybody tell me the reason?</p>
  
  <p>Thank
  Angelo</p>
  
  <p>I'll give you some detail; I built a class for my own history management; I built this class:</p>
  
  <pre><code>public class GwtHistoryEventsMgr {
  
  
  private Map&lt;String, List&lt;GwtEvent&gt;&gt; tknEvts;
  private HandlerManager eventBus;
  public GwtHistoryEventsMgr(HandlerManager evtBus){
  
      tknEvts = new HashMap&lt;String, List&lt;GwtEvent&gt;&gt;();
      this.eventBus = evtBus;
  
  }
  
  private void saveHistoryEvent( GwtEvent event ){
  
      List&lt;GwtEvent&gt; eventi = null;
      if( tknEvts.containsKey(History.getToken()) ){
  
          eventi = tknEvts.get(History.getToken());
      }else{
  
          eventi = new ArrayList&lt;GwtEvent&gt;();
      }
      eventi.add(event);
      tknEvts.put(History.getToken(), eventi);
  }
  public void addEvtHandlers(){
  
      //Aggiungo gli handler 
      eventBus.addHandler(CustomEvent.TYPE, new CustomEventHandler() {
  
          @Override
          public void onEvent(CustomEvent event) {
  
              saveHistoryEvent(event);
          }
      });
  
  }
  public List&lt;GwtEvent&gt; getTokenTransWidgetEvents(String token){
  
      if( tknEvts.containsKey(token) ){
  
          return tknEvts.remove(token);
      }else{
  
          return null;
      }
  }
  }
  </code></pre>
  
  <p>Then in my AppController constructor I wrote this code:</p>
  
  <pre><code>public AppController(HandlerManager eventBus, StandardDispatchAsync dispatcher){
      super(null);
      this.eventBus = eventBus;
      this.dispatcher = dispatcher;
      //Gestione history
      histMgr = new GwtHistoryEventsMgr(eventBus);
      histMgr.addEvtHandlers();
  }
  </code></pre>
  
  <p>This means that I should be pretty sure that the AppController registers itself to the events I want (note: I strongly reduced the code...but all the code is in the way I wrote)</p>
  
  <p>Then, since I use client-side reflection, I did, where I use the client side reflection, this code (after that all widgets have been initialized):</p>
  
  <pre><code>@SuppressWarnings("rawtypes")
  private void generateHistoricalEvents(){
  
      List&lt;GwtEvent&gt; eventi = hisMgr.getTokenTransWidgetEvents(History.getToken());
      //Ci sono eventi....vuol dire back del browser cliccato
      if( eventi != null ){
  
          for (GwtEvent gwtEvent : eventi) {
  
              this.eventBus.fireEvent(gwtEvent);
          }
      }
  }
  </code></pre>
  
  <p>According to me it's all OK; may you tell me where the problem is?</p>
  
  <p>Thank you
  Angelo</p>