Frage

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));
}
War es hilfreich?

Lösung

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

Andere Tipps

Is this GWTP and if so how are you registering your events/handlers? I seem to recall there is a pitfall that you can use either @ProxyEvent or addRegisteredHandler() but not both, or you will receive the events twice.

Hope that helps.

Cheers,

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top