eventsgwtgwt-platformgwtp

GWTP: event sent once but received (handler) twice


On GWTP I am sending a UpdateDiagramBoxEvent with the code below, but the handler is executed twice. In other words, I can see that the sendUpdateDiagramBoxEvent() is executed only once, but it is received twice. The same is happening with many other events on my code. Any ideas of what is wrong, and how can I avoid this behaviour? THANKS.

Receive event

UpdateDiagramBoxHandler updateDiagramBoxHandler = new UpdateDiagramBoxHandler() {
  @Override
  public void onUpdateDiagramBox(UpdateDiagramBoxEvent event) {
    doSomething();
  }
};

Send event

EventUtil.sendUpdateDiagramBoxEvent(CellTableManager.this.eventBus, 
  BasicConstants.EventSubscriptors.VIEW, 0, 
  BasicConstants.EditableTableFields.DIAGRAMTYPE,                                           
  ClientState.getCurrentDiagramType().name());

public static void sendUpdateDiagramBoxEvent(final EventBus eventBus, 
    final BasicConstants.EventSubscriptors recipient, 
    final int index, final BasicConstants.EditableTableFields field, 
    final String value){

    Scheduler.get().scheduleDeferred(new ScheduledCommand() {    
        @Override
    public void execute() {
      UpdateDiagramBoxEvent updateDiagramBoxEvent = 
        new UpdateDiagramBoxEvent(transactionNumber, recipient, 
            field.toString(), value, index);
        eventBus.fireEvent(updateDiagramBoxEvent);
        }                               
    });
  }

Register event handler (from MyProjectPresenter.java)

@Inject PlaceManager placeManager;
@Override
protected void onBind() {
   [...]                      
       registerHandler(getEventBus().addHandler(UpdateDiagramBoxEvent.getType(),
       updateDiagramBoxHandler));
}

Solution

  • It generally means that you simply registered your event handlers twice.