在GWTP中,如何处理TabLayoutPanel事件?

在GWTP中,如何处理TabLayoutPanel事件?,gwt,gwtp,Gwt,Gwtp,我学习了Dani的GWTP课程,但不包括与演示者一起使用TabLayoutPanel 我有一个TabLayoutPanel,有3个选项卡,每个选项卡上有一个垂直面板。我使用了@ProxyCodeSplit,因此每个选项卡的代码都是独立加载的 如果在Eclipse中,我在GWT的设计器中为OnBeforeSelection添加了一个处理程序,那么代码将自动添加到我的视图中。然后,视图可以加载相应的演示者 这感觉不是代码的正确位置-但它是吗 你是如何在TabLayoutPanel和代码拆分中处理不同

我学习了Dani的GWTP课程,但不包括与演示者一起使用TabLayoutPanel

我有一个TabLayoutPanel,有3个选项卡,每个选项卡上有一个垂直面板。我使用了@ProxyCodeSplit,因此每个选项卡的代码都是独立加载的

如果在Eclipse中,我在GWT的设计器中为OnBeforeSelection添加了一个处理程序,那么代码将自动添加到我的视图中。然后,视图可以加载相应的演示者

这感觉不是代码的正确位置-但它是吗


你是如何在TabLayoutPanel和代码拆分中处理不同的选项卡的?

我想我已经解决了这个问题

在带有TabLayoutPanel的presenter中,我们将其称为MainPresenter:

@ContentSlot public static final Type<RevealContentHandler<?>> SLOT_first = new Type<RevealContentHandler<?>>();
@ContentSlot public static final Type<RevealContentHandler<?>> SLOT_second = new Type<RevealContentHandler<?>>();

public interface MyView extends View {
    public void setMainPresenter(MainPresenter presenter);
    public TabLayoutPanel getTeamsPanel();
}

@Inject PlaceManager placeMananger;
@Inject FirstPresenter firstPresenter;
@Inject SecondPresenter secondPresenter;

@ProxyCodeSplit
public interface MyProxy extends Proxy<MainPresenter> {
}

@Inject
public MainPresenter(final EventBus eventBus, final MyView view,
        final MyProxy proxy) {
    super(eventBus, view, proxy);
    view.setMainPresenter(this);
}

@Override
protected void revealInParent() {
    RevealRootContentEvent.fire(this, this);
}

public void setTabContents(Integer tab) {
    if (tab == 0) {
        placeMananger.revealPlace(new PlaceRequest("first"));
    } else if (tab == 1) {
        placeMananger.revealPlace(new PlaceRequest("second"));
}
然后在MainView中实现setMainPresenter方法以在本地存储引用。实现通常的setInSlot,然后添加此选项卡处理程序:

@UiHandler("mainTabs")
void onMainTabsBeforeSelection(BeforeSelectionEvent<Integer> event) {
    mainPresenter.setTabContents(event.getItem());
}
每次用户更改选项卡时,处理程序都将调用MainPresenter。setTabContents随后将为相应的选项卡演示者调用revealInParent