0

ViewWithUiHandlers を使用してすべてのビューを拡張しています。したがって、View からプレゼンター メソッドを呼び出すために呼び出します。

 getUiHandlers().OnUserSelect();

クラスは複数の拡張を持つことができないため、ビューの 1 つが DialogBox を拡張する必要がある場合、getUiHandlers() を取得するにはどうすればよいですか。

4

2 に答える 2

0

基本的なポップアップの例を次に示します。まず、にPresenterWidget関連付けられた を作成する必要がありますPopupViewWithUiHandler:

 public class MyPopupPresenter extends PresenterWidget<MyPopupPresenter.MyView>
        implements MyPopupUiHandlers {
    public interface MyView extends PopupView, HasUiHandlers<MyPopupUiHandlers> {
    }

    @Inject
    public MyPopupPresenter(EventBus eventBus,
                            MyView view) {
        super(eventBus, view);

        getView().setUiHandlers(this);
    }
}

ここにあなたのPopupViewWithUiHandlers

public class MyPopupView extends PopupViewWithUiHandlers<MyPopupUiHandlers>
        implements MyPopupPresenter.MyView, {
    public interface Binder extends UiBinder<PopupPanel, MyPopupView> {
    }

    @Inject
    public MyPopupView(Binder binder,
                       EventBus eventBus) {
        super(eventBus);

        initWidget(binder.createAndBindUi(this));
    }
}

に関連付けられている UiBinder は次のとおりPopupViewWithUiHandlersです。次の点に注意して<g:PopupPanel>ください。

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
             xmlns:g='urn:import:com.google.gwt.user.client.ui'>
    <g:PopupPanel>
        <g:HTMLPanel>
            ...
        </g:HTMLPanel>
    </g:PopupPanel>
</ui:UiBinder>

addToPopupSlot(myPopupPresenter)また、 parentを呼び出してポップアップを表示できますPresenter

public class MyPresenter extends Presenter<MyPresenter.MyView, MyPresenter.MyProxy>       implements MyUiHandlers {
    public interface MyView extends View, HasUiHandlers<MyUiHandlers> {
    }

    @ProxyStandard
    @NameToken(NameTokens.myNameToken)
    public interface MyProxy extends ProxyPlace<MyPresenter> {
    } 

    private final MyPopupPresenter myPopupPresenter;

    @Inject
    public MyPresenter(EventBus eventBus,
                       MyView view,
                       MyProxy proxy,
                       MyPopupPresenter myPopupPresenter) {
        super(eventBus, view, proxy, ApplicationPresenter.MainContentSlot);

        this.myPopupPresenter = myPopupPresenter;

        getView().setUiHandlers(this);
    }

    private void showPopup() {
        addToPopupSlot(myPopupPresenter); // this will show your popup
    }
}
于 2013-04-18T13:15:40.160 に答える
0

見るPopupViewWithUiHandler

于 2013-01-22T22:58:11.293 に答える