0

前几天我发了一个问题,没有得到太多回应。我尝试了几件事,但仍然没有运气。我正在尝试在 GWTP 中嵌套一个选项卡演示器。我有一帧(北)是选项卡组 1 和一帧(西)是选项卡组 2。当我与组 1 交互时,我更新了控制组 2 的嵌套选项卡演示器。我查看了嵌套选项卡的示例演示者,但我无法从中确定我的错误。

两个 TabContainerPresenter 是 ManagementTabsPresenter 和 SettingsTabsPresenter。这些的孩子就像下面的 HomePresenter。这些子项的内容显示在位于 MainPreseter 的 DockLayoutPanel 的中心。我希望 ManagementTabsPresenter 和 SettingsTabsPresenter 显示在同一个 DockLayoutPanel 的 West 插槽中。

当我运行此代码时,所有内容都放置在屏幕上的正确位置。您甚至可以单击选项卡并执行操作。问题始于首先显示 SettingsPresenter,即使默认页面是 HomePresenter。就像它试图在启动时同时显示两者一样。然后,当您选择属于​​ ManagementTabsPresenter 或 SettingsTabsPresenter 的任何选项卡时,它将在 MainPresenter.Center_Slot 中打开正确的内容,但在 MainPresenter.West_Slot 中显示不正确的演示者。我无法弄清楚这里出了什么问题。任何帮助,将不胜感激。

这是代码:

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("home", 0);
}

@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 NonLeafTabContentProxy<ManagementTabsPresenter> {
}

/**
 * {@link ManagementTabsPresenter}'s view.
 */
public interface MyView extends TabView {
}

/**
 * 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>();

@TabInfo(container = HeaderTabsPresenter.class, nameToken = NameTokens.homePage)
static TabData getTabLabel(MainAppGinjector injector) {
    return new TabDataBasic("Management", 0);
}

@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);
}


@Override
protected void revealInParent() {
    RevealContentEvent.fire(this,  HeaderTabsPresenter.TYPE_VERTICAL_TABS_SLOT, this);
}
}



public class SettingsTabsPresenter extends TabContainerPresenter<SettingsTabsPresenter.MyView, SettingsTabsPresenter.MyProxy> {

/**
 * {@link SettingsTabsPresenter}'s proxy.
 */
@ProxyStandard
public interface MyProxy extends NonLeafTabContentProxy<SettingsTabsPresenter> {
}

/**
 * {@link SettingsTabsPresenter}'s view.
 */
public interface MyView extends TabView {
}

@TabInfo(container = HeaderTabsPresenter.class, nameToken = NameTokens.appUserCollectionPage)
static TabData getTabLabel(MainAppGinjector injector) {
    return new TabDataBasic("Settings", 1);
}

/**
 * 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 SettingsTabsPresenter(final EventBus eventBus, final MyView view,
                               final MyProxy proxy,  AppPlaceManager appPlaceManager) {
    super(eventBus, view, proxy,TYPE_MAIN_CONTENT_SLOT, TYPE_Settings_RequestTabs);
}


@Override
protected void revealInParent() {
    RevealContentEvent.fire(this,  HeaderTabsPresenter.TYPE_VERTICAL_TABS_SLOT, this);
}
}


public class HeaderTabsPresenter extends TabContainerPresenter<HeaderTabsPresenter.MyView, HeaderTabsPresenter.MyProxy> {
@Inject EventBus eventBus;

/**
 * {@link HeaderTabsPresenter}'s proxy.
 */
@ProxyStandard
public interface MyProxy extends Proxy<HeaderTabsPresenter> {
}

/**
 * {@link HeaderTabsPresenter}'s view.
 */
public interface MyView extends TabView {
    void changeTab(Tab tab, TabData tabData, String historyToken);
}

/**
 * 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_HEADER_RequestTabs = new Type<RequestTabsHandler>();

/**
 * Fired by child proxie's when their tab content is changed.
 */
@ChangeTab
public static final Type<ChangeTabHandler> TYPE_HEADER_ChangeTab = new Type<ChangeTabHandler>();

@ContentSlot
public static final Type<RevealContentHandler<?>> TYPE_VERTICAL_TABS_SLOT = MainPresenter.WEST_SLOT;

@Inject
public HeaderTabsPresenter(final EventBus eventBus, final MyView view,
                           final MyProxy proxy) {
    super(eventBus, view, proxy, TYPE_VERTICAL_TABS_SLOT, TYPE_HEADER_RequestTabs, TYPE_HEADER_ChangeTab);
}


@Override
protected void revealInParent() {
     RevealContentEvent.fire(this, MainPresenter.NORTH_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();
}

}
4

1 回答 1

0

我之前偶然发现了类似的东西......我认为这是因为它们都继承自 TabContainerPresenter 并且 gwtp 中有一个错误会在错误的继承子节点上调用 onReveal() 。

看看这个 gwtp 论坛帖子: https ://groups.google.com/forum/?fromgroups#!searchin/gwt-platform/gilad$20egozi/gwt-platform/p0s3BlN-ceE/5EL3nynaiu4J

是这样吗?如果是这样,我认为没有人在 gwtp 问题跟踪器上提交错误,所以请告诉我。

(当然,最好的检查是不要继承,看看它是否有效)

于 2012-07-05T15:05:34.600 回答