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)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to