GWTP 未显示 UI

GWTP not displaying UI

我试图在我的 GWT 2.7 应用程序中使用 GWTP,但我的 uibinder 中的 UI 没有显示。我的应用程序在超级开发模式下编译和运行没有任何错误,但我得到一个空白屏幕。我希望 LayoutView.ui.xml 中的 HTML 显示在浏览器中。我确定我错过了一些非常基本的东西。任何帮助都会很棒。

以下内容包含在我的 .gwt.xml 文件中

  <inherits name='com.google.gwt.inject.Inject' />

  <!-- Other module inherits                                      -->
  <inherits name="com.google.gwt.uibinder.UiBinder" />
  <inherits name='com.gwtplatform.mvp.Mvp' />

  <entry-point class="com.clearwood.client.App" />

  <define-configuration-property name="gin.ginjector" is-multi-valued="false" />
  <set-configuration-property name="gin.ginjector"
   value="com.clearwood.client.gin.MyGinjector" /> 

client/App.java

public class App implements EntryPoint {
    public final MyGinjector ginjector = GWT.create(MyGinjector.class);

    @Override
    public void onModuleLoad() {
        DelayedBindRegistry.bind(ginjector);
        ginjector.getPlaceManager().revealCurrentPlace();      
    }
}

client/gin/ClientModule.java

public class ClientModule extends AbstractPresenterModule {
    @Override
    protected void configure() {
        install(new DefaultModule());
        install(new LayoutModule());

        bindConstant().annotatedWith(DefaultPlace.class).to(NameTokens.LAYOUT);
        bindConstant().annotatedWith(ErrorPlace.class).to(NameTokens.LAYOUT);
        bindConstant().annotatedWith(UnauthorizedPlace.class).to(NameTokens.LAYOUT);

        requestStaticInjection(NameTokens.class);
     }
}

client/gin/Ginjector.java

@GinModules({ ClientModule.class })
public interface MyGinjector extends Ginjector {
  EventBus getEventBus();   
  PlaceManager getPlaceManager();
  Provider<LayoutPresenter> getLayoutPresenter();
}

client/place/NameTokens.java

public class NameTokens {
    public static final String LAYOUT = "LAYOUT";
    public static String getLAYOUT() {
        return LAYOUT;
    }
}

client/layout/LayoutView.ui.xml

<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
         xmlns:g="urn:import:com.google.gwt.user.client.ui">
 <g:SimplePanel width="600px" height="auto" ui:field="main">
    <g:HTML width="100%" height="100%">TEST</g:HTML>
 </g:SimplePanel>
</ui:UiBinder>

client/layout/LayoutView.java

class LayoutView extends ViewImpl implements LayoutPresenter.MyView {
    interface Binder extends UiBinder<Widget, LayoutView> {
    }

    @UiField
    SimplePanel main;

    @Inject
    LayoutView(Binder uiBinder) {
        initWidget(uiBinder.createAndBindUi(this));
    }

    @Override
    public void setInSlot(Object slot, IsWidget content) {
        if (slot == LayoutPresenter.SLOT_Layout) {
            main.setWidget(content);
        } else {
            super.setInSlot(slot, content);
        }
    }
}

client/layout/LayoutPresenter.java

public class LayoutPresenter extends Presenter<LayoutPresenter.MyView, LayoutPresenter.MyProxy>  {
    interface MyView extends View  {
    }
    @ContentSlot
    public static final Type<RevealContentHandler<?>> SLOT_Layout = new Type<RevealContentHandler<?>>();

    @ProxyStandard
    interface MyProxy extends Proxy<LayoutPresenter> {
    }

    @Inject
    LayoutPresenter(
            EventBus eventBus,
            MyView view, 
            MyProxy proxy) {
        super(eventBus, view, proxy, RevealType.Root);
    }
}

client/layout/LayoutModule.java

public class LayoutModule extends AbstractPresenterModule {
    @Override
    protected void configure() {
        bindPresenter(LayoutPresenter.class, LayoutPresenter.MyView.class, LayoutView.class, LayoutPresenter.MyProxy.class);
    }
 }

我使用 GWTP 插件生成了 Layout Presenter。 我试着按照示例教程进行操作 http://dev.arcbees.com/gwtp/sampletutorial/https://code.google.com/p/gwt-platform/wiki/GettingStarted#Getting_the_sample_applications 但其中一些似乎已被弃用

您没有带 ProxyPlace 和注释 @NameToken 的演示者。为了让您的代码快速运行,您可以将 LayoutPresenter.MyProxy 更改为:

@ProxyStandard
@NameToken(NameTokens.LAYOUT)
interface MyProxy extends ProxyPlace<LayoutPresenter> {}

此外,Google 代码文档实际上已过时很多。到处都是警告,所以我认为这是显而易见的。

关于 https://dev.arcbees.com/gwtp/sampletutorial/ is recent enough to help you develop a working application. You can also have a look at GWTP's Basic Sample for more examples: https://github.com/ArcBees/GWTP-Samples/tree/master/gwtp-samples/gwtp-sample-basic

的文档