In my design I want to have a view/presenter pair where the presenter is an abstract class that gets extended. For example, my design consists of a bunch of questions that get asked one at a time. I might have a view/presenter pair for a yes/no question. I would want to have a YesOrNo presenter with abstract methods like getQuestion, onYes, onNo. The reveal of this presenter would set question and the overloaded uibinderHandlers would call onYes and onNo. I might then extend the YesOrNo presenter with HasDogYesOrNo presenter which would contain the bussiness logic on what to do if the use has a dog. I might have something similar for HasCatYesOrNo.
So I created the two classes that extend a generic
YesNoPresenter<T extends Proxy<?>> extends Presenter<YesNo.MyView, T>
and each then I define the classes like
public class HasCatsYesNoPresenter extends YesNoPresenter<HasCatsYesNoPresenter.MyProxy>
When I go to bind them I have
bindPresenter(YesNoPresenter.class, YesNoPresenter.MyView.class, YesNoView.class,
HasCatsYesNoPresenter.MyProxy.class);
bindPresenter(YesNoPresenter.class, YesNoPresenter.MyView.class, YesNoView.class,
HasDogsYesNoPresenter.MyProxy.class);
But I get an error that
$MyView is Double-bound: Bound at com.gwtplatform.mvp.client.gin.AbstractPresenterModule ...
It seems that I can't bind two presenters to the same view? I really wanted to reuse views but put different business logic behind them. Is there a better way to do this in GWTP? My must haves is reuse the same view with different business logic presenter and have each of those business logic presenters be bookmarkable. A like to have would be to also have my business logic presenters to be anonymous classes, but that might be asking too much.
There are other ways to implement my presenters for my simple YesNo case, but I have some more complicated presenters that I think the best way to reuse code is to extend a base presenter with the logic needed for that presenter. The yesnopresenter was just an example.