Tristan
unread,May 20, 2009, 5:50:31 PM5/20/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google Web Toolkit
Hello,
I am stuck with the fact that HandlerRegistration.removeHandler() is
not removing my handler.
I have two controllers, say ParentController and ChildController,
each
implements ValueChangeHandler<String> to handle history events
The root class extended by both parent and child controllers:
public abstract class RootController implements
ValueChangeHandler<String>{
protected Controller parent = null;
protected HandlerRegistration historyHandler = null;
protected HashMap<String, Controller> childControllers = new
HashMap<String, Controller>(4);
public RootController(Controller parent){
this.parent = parent;
}
public giveHistoryControlTo(RootController controller){
historyHandler.removeHandler();
controller.setHistoryHandler( History.addValueChangeHandler
(controller));
History.fireCurrentHistoryState();
}
}
public class ParentController extends RootController implements Entry
Point {
public void onModuleLoad() {
childControllers.put( ChildController.NAME, new ChildController
(this));
historyHandler = History.addValueChangeHandler(this);
History.fireCurrentHistoryState():
}
.... at some point ParentController executes:
giveHistoryControlTo( childController.get
(ChildController.NAME));
**** the above works fine, handler is removed and new event is
**** handled by the child controller
}
public class ChildController extends RootController{
public ChildController(ParentController parent){
super(parent);
}
.... at some point ChildController executes:
giveHistoryControlTo( (ParentController) parent );
**** the above fails!!!
**** it appears as though handler is not removed as the
**** History.fireCurrentHistoryState() inside
giveHistoryControlTo
()
**** is being handled by the ChildController, instead of parent :
(
}
Feels like a bug. Is there a reason why .removeHandler() would not
immediately
do what it is supposed to?
- Tristan
ps.
"God helps those who help themselves"
I hacked a workaround. But the bug still remains.
(workaround was setting historyHandler to null when
giving up control and then explicitly calling the
parent's onValueChange() if historyHandler == null)