嘿,所以我只是在学习 gwtp 框架,我遇到了一些困境。我在顶层有一个 LayoutPresenter,它有一个主内容槽和菜单内容槽,我正在尝试找到一种方法将每个槽的演示者绑定在一起,以便在显示主要内容时它会自动显示正确的一面菜单。目前,我在菜单的 Presenter 中有一个静态布尔值,它会更新 onReveal 和 onHide。然后,我可以检查显示主要内容时菜单是否可见,如果不可见,我会显示它。
public class MenuPresenter extends Presenter<MenuPresenter.MyView, MenuPresenter.MyProxy> {
private static boolean hidden = true;
...
@Override
protected void revealInParent() {
RevealContentEvent.fire(this, LayoutPresenter.SIDE, this);
}
@Override
protected void onReveal(){
super.onReveal();
hidden = false;
}
@Override
protected void onHide(){
super.onHide();
hidden = true;
}
public static boolean isHidden(){
return hidden;
}
}
然后在主要内容Presenter中:
public class ContentPresenter extends
Presenter<ContentPresenter.MyView, ContentPresenter.MyProxy> {
...
private final DispatchAsync dispather;
private final PlaceManager placeManager;
@Inject
public PhoneCallPresenter(final EventBus eventBus, final MyView view, final MyProxy proxy, final DispatchAsync dispatcher, final PlaceManager placeManager) {
super(eventBus, view, proxy);
this.dispather = dispatcher;
this.placeManager = placeManager;
}
@Override
protected void revealInParent() {
RevealContentEvent.fire(this, LayoutPresenter.CONTENT, this);
}
@Override
protected void onReveal() {
super.onReveal();
if (MenuPresenter.isHidden()){
placeManager.revealPlace(new PlaceRequest(NameTokens.menu));
}
}
}