2015-08-09 95 views
0

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

包括在我的.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();  
    } 
} 

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

客户机/杜松子酒/ 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插件布局主持人。 我试图按照样品教程在 http://dev.arcbees.com/gwtp/sampletutorial/https://code.google.com/p/gwt-platform/wiki/GettingStarted#Getting_the_sample_applications 但有些事情似乎是过时

回答

1

你不必用ProxyPlace并在其上标注@NameToken演示。为了让你的代码快速的工作,你可以改变LayoutPresenter.MyProxy到:

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

而且谷歌代码文件由很多实际上已经过时。各地都有警告,所以我认为这很明显。

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

+0

谢谢克里斯托弗。它现在工作:) – user3359702