GWT场所和活动 - 获得重复的UI

时间:2014-03-27 13:04:04

标签: java gwt

我是GWT的新手,并尝试实施活动和地点。我正面临着UI的问题。我无法发布图片,因为我是Stackoverflow的新手并且没有10个声望点,但我在左边看到一个面板两次。我还附加了启动器代码和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());
}
}

1 个答案:

答案 0 :(得分:1)

您不应将视图直接添加到RootPanel。相反,你应该添加你的appWidget:

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

当您从一个地方导航到下一个地方时,ActivityManager将添加和隐藏视图。