PDA

View Full Version : Dispatcher problem/help



articlaus
8 Mar 2011, 1:35 AM
I am not sure whether this is a bug or my lack of knowledge.
but whenever i use a dispatcher Controller with Listener.
the DispatcherListener is keep getting two events rather than one..
here is my code snippet.
In onModuleLoad

final Button button = new Button("Click me");
Dispatcher dispatcher = Dispatcher.get();
dispatcher.addController(new ClickController());
dispatcher.addDispatcherListener(new ClickListener());
button.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
dispatcher.dispatch(new EventType(1));
}
});
in ClickController

public class ClickController extends Controller {
@Override
public void handleEvent(AppEvent event) {
System.out.println("Event Handling");
}
}
in Click Listener

public class ClickListener extends DispatcherListener {
@Override
public void handleEvent(MvcEvent e) {
System.out.println("getting");
}
}

and when i run and execute the prog it always prints two Getting per button click.
please some one help. i am going crazy over this.

gishmo
9 Mar 2011, 12:23 AM
I'll suggest to print the event types. May be you get two, something like BeforeSelect and Select when you click the button.