我正在尝试在GWTP中嵌套标签展示器。我有一个框架(北)是选项卡组1和一个框架(西),它是选项卡组2.当我与组1交互时,我更新了控制组2的嵌套选项卡显示器。我已经查看了嵌套选项卡的示例主持人,但我无法从中确定我的错误。
两个TabContainerPresenters是ManagmentTabsPresenter和SettingsTabsPresenter。这些孩子就像下面的HomePresenter。这些子项的内容显示在DockLayoutPanel的中心。我希望ManagementTabsPresenter和SettingsTabsPresenter显示在同一个DockLayoutPanel的West插槽中。
我看到的问题是,当运行此代码时,只要我尝试在子选项卡上查看一个,就会调用ManagementTabsPresenter的revealInParent()方法和SettingsTabsPresenter的revealInParent()方法。 (即homePresenter)。为什么这两个revealInParent方法都被调用?我错过了什么?确实,SettingsTabsPresenter和ManagementTabsPresenter都在显示的父选项卡中。这是否意味着当父tabcontainerpreseter被显示为显性时,将调用这两个tabcontainerprestner(nonleavetabcontentproxy)的revealInParent?
public class HomePresenter extends Presenter<HomePresenter.MyView, HomePresenter.MyProxy> {
@Inject
AppPlaceManager appPlaceManager;
@NameToken(NameTokens.homePage)
@ProxyStandard
@NoGatekeeper
public interface MyProxy extends TabContentProxyPlace<HomePresenter> {
}
public interface MyView extends View {
}
@TabInfo(container = ManagementTabsPresenter.class)
static TabData getTabLabel(MainAppGinjector injector) {
return new TabDataBasic(injector.getVSMMessages().home_tab(), ClientConstants.HOME_TAB_POSITION);
}
@Inject
public HomePresenter(final EventBus eventBus, final MyView view, final MyProxy proxy) {
super(eventBus, view, proxy);
}
@Override
protected void revealInParent() {
RevealContentEvent.fire(this, ManagementTabsPresenter.TYPE_MAIN_CONTENT_SLOT, this);
}
}
public class ManagementTabsPresenter extends TabContainerPresenter<ManagementTabsPresenter.MyView, ManagementTabsPresenter.MyProxy> {
/**
* {@link ManagementTabsPresenter}'s proxy.
*/
@ProxyStandard
public interface MyProxy extends Proxy<ManagementTabsPresenter> {
}
/**
* {@link ManagementTabsPresenter}'s view.
*/
public interface MyView extends TabView {
}
/**
* Fired by child proxie's when their tab content is changed.
*/
@ChangeTab
public static final Type<ChangeTabHandler> TYPE_Management_ChangeTab = new Type<ChangeTabHandler>();
/**
* Use this in leaf presenters, inside their {@link #revealInParent} method.
*/
@ContentSlot
public static final GwtEvent.Type<RevealContentHandler<?>> TYPE_MAIN_CONTENT_SLOT = MainPresenter.CENTER_SLOT;
/**
* This will be the event sent to our "unknown" child presenters, in order for
* them to register their tabs.
*/
@RequestTabs
public static final Type<RequestTabsHandler> TYPE_Management_RequestTabs = new Type<RequestTabsHandler>();
@Inject
public ManagementTabsPresenter(final EventBus eventBus, final MyView view,
final MyProxy proxy, AppPlaceManager appPlaceManager) {
super(eventBus, view, proxy,TYPE_MAIN_CONTENT_SLOT, TYPE_Management_RequestTabs, TYPE_Management_ChangeTab);
}
@Override
protected void revealInParent() {
RevealContentEvent.fire(this, MainPresenter.WEST_SLOT, this);
}
}
public class SettingsTabsPresenter extends TabContainerPresenter<SettingsTabsPresenter.MyView, SettingsTabsPresenter.MyProxy> {
/**
* {@link SettingsTabsPresenter}'s proxy.
*/
@ProxyStandard
public interface MyProxy extends Proxy<SettingsTabsPresenter> {
}
/**
* {@link SettingsTabsPresenter}'s view.
*/
public interface MyView extends TabView {
}
/**
* Fired by child proxie's when their tab content is changed.
*/
@ChangeTab
public static final Type<ChangeTabHandler> TYPE_Settings_ChangeTab = new Type<ChangeTabHandler>();
/**
* Use this in leaf presenters, inside their {@link #revealInParent} method.
*/
@ContentSlot
public static final GwtEvent.Type<RevealContentHandler<?>> TYPE_MAIN_CONTENT_SLOT = MainPresenter.CENTER_SLOT;
/**
* This will be the event sent to our "unknown" child presenters, in order for
* them to register their tabs.
*/
@RequestTabs
public static final Type<RequestTabsHandler> TYPE_Settings_RequestTabs = new Type<RequestTabsHandler>();
@Inject
public ManagementTabsPresenter(final EventBus eventBus, final MyView view,
final MyProxy proxy, AppPlaceManager appPlaceManager) {
super(eventBus, view, proxy,TYPE_MAIN_CONTENT_SLOT, TYPE_Settings_RequestTabs, TYPE_Settings_ChangeTab);
}
@Override
protected void revealInParent() {
RevealContentEvent.fire(this, MainPresenter.WEST_SLOT, this);
}
}
public class MainPresenter extends Presenter<MainPresenter.MyView, MainPresenter.MyProxy>{
@Inject VSMRequestFactory requestFactory;
@Inject VSMMessages vsmMessages;
@Inject VSMExceptionMessages vsmExceptionMessages;
@Inject EventBus eventBus;
@ProxyStandard
@NoGatekeeper
public interface MyProxy extends Proxy<MainPresenter> {
}
public interface MyView extends View {
}
@ContentSlot
public static final Type<RevealContentHandler<?>> SOUTH_SLOT = new Type<RevealContentHandler<?>>();
@ContentSlot
public static final Type<RevealContentHandler<?>> WEST_SLOT = new Type<RevealContentHandler<?>>();
@ContentSlot
public static final Type<RevealContentHandler<?>> CENTER_SLOT = new Type<RevealContentHandler<?>>();
@ContentSlot
public static final Type<RevealContentHandler<?>> NORTH_SLOT = new Type<RevealContentHandler<?>>();
@Inject
public MainPresenter(EventBus eventBus, MyView view, MyProxy proxy) {
super(eventBus, view, proxy);
}
@Override
protected void revealInParent() {
RevealRootLayoutContentEvent.fire(this, this);
}
@Override
protected void onReveal() {
super.onReveal();
initializeAppUser();
}
}
答案 0 :(得分:0)
这应该是一个事件问题,当您选择一个选项卡时,SelectionEvent可能被错误的选项卡使用。你能添加一些关于标签初始化的代码吗?