2015-08-09 99 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