GWTP
GWTP copied to clipboard
Unnecessary OnReveal() called?
Assume we have 3 presenters:
Main Presenter:
public class MainPresenter extends Presenter<MainPresenter.MyView,
MainPresenter.MyProxy> implements MainUiHandlers{
private static final Logger logger = Logger.getLogger(MainPresenter.class.getSimpleName());
private final PlaceManager placeManager;
private static final String TOKEN = NameTokens.landing;
@ProxyStandard
@NameToken(TOKEN)
@NoGatekeeper
public interface MyProxy extends ProxyPlace<MainPresenter> {
}
public interface MyView extends View, HasUiHandlers<MainUiHandlers>{
}
@Override
public void goTest() {
placeManager.revealPlace(new PlaceRequest.Builder().nameToken(NameTokens.test).build());
}
@Override
public void goTest1() {
placeManager.revealPlace(new PlaceRequest.Builder().nameToken(NameTokens.test1).build());
}
@Inject
public MainPresenter(EventBus eventBus,
MyView view,
MyProxy proxy,
PlaceManager placeManager) {
super(eventBus, view, proxy, RevealType.Root);
this.placeManager = placeManager;
this.getView().setUiHandlers(this);
}
TestPresenter & Test1Presenter (almost the same, they are child presenters of AplicationPresenter)
public class TestPresenter extends Presenter<TestPresenter.MyView,
TestPresenter.MyProxy> implements TestUiHandlers{
private static final Logger logger = Logger.getLogger(TestPresenter.class.getSimpleName());
private final PlaceManager placeManager;
private static final String TOKEN = NameTokens.test;
@ProxyCodeSplit
@NameToken(TOKEN)
@NoGatekeeper
public interface MyProxy extends ProxyPlace<TestPresenter> {
}
public interface MyView extends View, HasUiHandlers<TestUiHandlers>{
}
@Inject
public TestPresenter(EventBus eventBus,
MyView view,
MyProxy proxy,
PlaceManager placeManager) {
super(eventBus, view, proxy, ApplicationPresenter.SLOT_WORKSPACE);
this.placeManager = placeManager;
this.getView().setUiHandlers(this);
}
@Override
protected void onBind() {
super.onBind();
logger.info("OnBind()");
}
@Override
protected void onReveal() {
super.onReveal();
logger.info("OnReveal()");
}
@Override
protected void onReset() {
super.onReset();
logger.info("onReset()");
ModuleVisibleEvent.fire(this, TOKEN);
}
@Override
public void onBack() {
placeManager.revealPlace(new PlaceRequest.Builder().nameToken(NameTokens.landing).build());
}
The ApplicationPresenter
public class ApplicationPresenter extends Presenter<ApplicationPresenter.MyView,
ApplicationPresenter.MyProxy> implements ModuleVisibleEvent.ModuleVisibleHandler, NavigationHandler {
private static final Logger logger = Logger.getLogger(ApplicationPresenter.class.getSimpleName());
private final PlaceManager placeManager;
@Override
public void onNavigation(NavigationEvent navigationEvent) {
logger.info("onNavigation()" + navigationEvent.getRequest().getNameToken());
}
@ProxyStandard
public interface MyProxy extends Proxy<ApplicationPresenter> {
}
public interface MyView extends View, HasUiHandlers<ApplicationUiHandlers> {
void onModuleVisible(String moduleName);
}
public static final NestedSlot SLOT_WORKSPACE = new NestedSlot();
The MainPresenter has 2 links: Test and Tes1, when navigate from MainPresenter to TestPresenter
and navigate back to MainPresenter, then navigate to Test1Presenter, the onReveal() of TestPresenter gets called before Test1Presenter revealed.The issue also exists when navigate from Test1Presenter to TestPresenter via MainPresenter.
The reason probably would be that when Test1Presenter gets revealed, in RevealContentHandler.onRevealContent(), it calls presenter.forceReveal() which checks if the parent presenter is visible or not, because the MainPresenter reveals from Root, ApplicationPresenter is invisible at the moment, so revealInParent() called which causes the previous presenter gets revealed.
Any comments?
Can anyone help with this issue? Many thanks.
Yes, we will try to look at that as soon as possible. Sorry for the delay.