2014-03-27 69 views
2

我是GWT的新手,並試圖實施活動和地點。我正面臨UI的問題。我無法發佈圖片,因爲我是Stackoverflow的新手,並且沒有10個聲望點,但我在左側看到了一個面板兩次。我還附加了啓動器代碼和UI綁定代碼。GWT的地方和活動 - 獲取重複的UI

public class SmartEBRM implements EntryPoint { 
//private Place defaultPlace = new SmartEBRMViewPlace("World!"); 

@SuppressWarnings("deprecation") 
@Override 
public void onModuleLoad() { 
    // TODO Auto-generated method stub 

    ClientFactory clientFactory = GWT.create(ClientFactory.class); 
    EventBus eventBus = clientFactory.getEventBus(); 
    PlaceController placeController = clientFactory.getPlaceController(); 

    // Start ActivityManager for the main widget with our ActivityMapper 
    ActivityMapper activityMapper = new AppActivityMapper(clientFactory); 
    ActivityManager activityManager = new ActivityManager(activityMapper, eventBus); 
    SmartEBRMViewImpl smartViewImpl = new SmartEBRMViewImpl(); 
    activityManager.setDisplay (smartViewImpl.getHTMLPannel()); 


    // Start PlaceHistoryHandler with our PlaceHistoryMapper 
    AppPlaceHistoryMapper historyMapper= GWT.create(AppPlaceHistoryMapper.class); 
    PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper); 
    SmartEBRMViewPlace smartViewPlace = new SmartEBRMViewPlace(); 
    historyHandler.register(placeController, eventBus, smartViewPlace); 
    historyHandler.handleCurrentHistory(); 

    RootPanel.get().add(smartViewImpl); 
} 
} 

public class SmartEBRMViewImpl extends Composite implements SmartEBRMView{ 
private static SmartEBRMViewImplUiBinder uiBinder = GWT 
     .create(SmartEBRMViewImplUiBinder.class); 

@UiField DockLayoutPanel docLayoutPanel; 
@UiField StackPanel stackPanel; 
@UiField Button enterpriseView; 
@UiField Button testComponent; 
@UiField SimplePanel centerPanel; 

private Presenter listener; 

interface SmartEBRMViewImplUiBinder extends 
     UiBinder<Widget, SmartEBRMViewImpl> { 
} 

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

public SmartEBRMViewImpl(String firstName) { 
    initWidget(uiBinder.createAndBindUi(this)); 
} 

@Override 
public void setPresenter(Presenter listener) { 
    // TODO Auto-generated method stub 
    this.listener = listener; 

} 

public SimplePanel getHTMLPannel() { 
    return centerPanel; 
} 

@UiHandler("enterpriseView") 
public void onClearButtonClick(ClickEvent e) 
{ 
    listener.goTo(new EnterpriseInvoiceCompareViewPlace()); 
} 
} 
+0

你爲什麼壓制「棄用」?你使用舊版本的EventBus嗎? –

回答

1

你不應該直接添加您欣賞到RootPanel。相反,你應該添加appWidget:

activityManager.setDisplay (appWidget); 
RootPanel.get().add(appWidget); 

的ActivityManager將添加和隱藏的觀點,你從一個地方轉到下一個。

+0

謝謝安德烈。這就是我現在做的.RootPanel.get().add(smartViewImpl.getHTMLPannel());但我想讓我的菜單在每個頁面上保持不變。現在,當我點擊按鈕時,它會將我導航到新頁面。我想這樣做,但在每個頁面上保持左側菜單不變。我想了解一下activityManager.setDisplay(smartViewImpl.getHTMLPannel());和RootPanel.get()。add(smartViewImpl.getHTMLPannel());.我其實並沒有在做什麼。 – gagan

+0

有兩種選擇:創建一個代表菜單的Widget,並將該Widget添加到每個視圖。或者,將應用分成兩部分:菜單部分和內容部分,併爲每個部分分別配備一個ActivityManager。你可以在這裏閱讀更多關於這個解決方案:http://blog.ltgt.net/gwt-21-activities-nesting-yagni/ –

+0

謝謝安德烈。我想我知道了:)(+1) – gagan