GWTP not displaying UI



我试图在我的GWT 2.7应用程序中使用GWTP,但我的binder中的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" /> 
客户机/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();      
    }
}

客户端/杜松子酒/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);
     }
}

客户端/杜松子酒/Ginjector.java

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

客户端/地方/NameTokens.java

public class NameTokens {
    public static final String LAYOUT = "LAYOUT";
    public static String getLAYOUT() {
        return 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>

客户端/布局/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);
        }
    }
}

客户端/布局/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);
    }
}

客户端/布局/LayoutModule.java

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

我使用GWTP插件生成了Layout演示器。我试着按照示例教程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 Code文档实际上已经过时了很多。到处都是警告,所以我认为这是显而易见的。

https://dev.arcbees.com/gwtp/sampletutorial/上的文档是最新的,足以帮助您开发工作应用程序。您还可以查看GWTP的基本示例以获取更多示例:https://github.com/ArcBees/GWTP-Samples/tree/master/gwtp-samples/gwtp-sample-basic

相关内容

  • 没有找到相关文章

最新更新