GWTP的嵌套演示者 [英] Nested presenters with GWTP
本文介绍了GWTP的嵌套演示者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的主演示者中有内容位置,如何在加载应用程序时将家庭演示者放在一个位置中,将菜单位置放置在另一个位置中?
I have content slots in my mainpresenter, how can i put, when app load, put the home presenter in one slot and the menu slot in the another ?
还是不可能?
提前谢谢.
推荐答案
可以!在下面的示例代码中,我假设您的HomePresenter是一个地方并扩展了Presenter,而您的MenuPresenter则扩展了PresenterWidget.
在您的MainPresenter中:
Yes you can ! In the following example code, I assume that your HomePresenter is a place and extends Presenter, and your MenuPresenter extends PresenterWidget.
In your MainPresenter :
@ContentSlot public static final Type<RevealContentHandler<?>> MAIN_SLOT = new Type<RevealContentHandler<?>>();
@ContentSlot public static final Type<RevealContentHandler<?>> MENU_SLOT = new Type<RevealContentHandler<?>>();
@Override
protected void onReveal() {
super.onReveal();
setInSlot(MENU_SLOT, menuPresenter);
}
在您的HomePresenter中:
In your HomePresenter :
@Override
protected void revealInParent() {
RevealContentEvent.fire(this, MainPresenter.MAIN_SLOT, this);
}
然后在MainView中:
Then in MainView :
@UiField Panel mainContainer;
@UiField Panel menuContainer;
@Override
public void setInSlot(Object slot, Widget content) {
if (slot == MainPresenter.MAIN_SLOT) {
mainContainer.clear();
mainContainer.add(content);
} else if (slot == MainPresenter.MENU_SLOT) {
menuContainer.clear();
menuContainer.add(content);
} else {
super.setInSlot(slot, content);
}
}
这篇关于GWTP的嵌套演示者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文