GWT - 每个选项卡的视图和演示者

时间:2015-02-02 13:35:03

标签: java gwt

我使用TabPanel为单页提供了一个视图和演示者,如下所示:

<g:TabPanel ui:field="tabPanel" addStyleNames="{style.versionTabs}">
    <g:Tab text="1">
        <g:FlowPanel>
        </g:FlowPanel>
    </g:Tab>
    <g:Tab text="2">
        <g:FlowPanel>
        </g:FlowPanel>
    </g:Tab>
    <g:Tab text="2">
        <g:FlowPanel>
        </g:FlowPanel>
    </g:Tab>
</g:TabPanel>

对于每个选项卡,我想创建新的Presenter和View以在选项卡之间分隔代码。

@UiHandler("tabPanel")
    void onTabSelection(SelectionEvent<Integer> event) {
        if (event.getSelectedItem() == ONE) {
            presenter.showOne();
        }
        if (event.getSelectedItem() == TWO) {
            presenter.showTwo();
        }
        if (event.getSelectedItem() == THREE) {
            presenter.showThree();
        }
    }

然后我有简单的视图和演示者(我有三个演示者和视图)

public class OneView extends Composite implements IOneView {

    @UiTemplate("OneView.ui.xml")
    interface OneViewUiBinder extends UiBinder<Widget, OneView> {
    }

    private static OneViewUiBinder uiBinder = GWT.create(OneViewUiBinder.class);

    @UiField
    Button startButton;

    public oneView() {
        initWidget(uiBinder.createAndBindUi(this));
    }

    @Override
    public Widget asWidget() {
        return this;
    }
}


<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" 
    xmlns:g="urn:import:com.google.gwt.user.client.ui"
    <g:HTMLPanel>
        Hallo,
        <g:Button ui:field="startButton" text="exemplary text" />
    </g:HTMLPanel>

和演示者

public class OnePresenter implements IOnePresenter {

    private IOneView view;
    private final Messages translation;

    public OnePresenter(ClientFactoryImpl factory, Messages messages) {
        this.view = factory.getOneView();
        this.translation = messages;
    }


    @Override
    public void go(HasWidgets container) {
        container.clear();
        container.add(view.asWidget());
    }
    @Override
    public void init() {    
    }
}

问题是,当用户点击主演示文稿中的标签后我创建新的演示者时,我看不到按钮

我做错了什么?

0 个答案:

没有答案