2013-01-22 99 views
0

我一直在用ViewWithUiHandlers擴展所有視圖。所以,從查看調用演示方法我稱之爲GWT ViewWithUiHandlers with DialogBox Uibinder

getUiHandlers().OnUserSelect(); 

我如何獲得getUiHandlers()當一個觀點必須擴展對話框,作爲一類不能有多個延伸。

回答

0

PopupViewWithUiHandler

+0

我已經試過PopupViewWithUiHandler,但我不能讓對話框功能的工作,這可能是因爲我缺乏知識。你能指導我使用PopupViewWithUiHandler UiBinder實現的一些例子嗎? – user874722

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

下面是相關聯的PopupViewWithUiHandlers的UiBinder的。注意<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> 

而且,您可以通過在父Presenter調用addToPopupSlot(myPopupPresenter)顯示彈出:

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 
    } 
}