2013-02-26 65 views
1

以下是項目中使用的總文件。這是給這些錯誤使用uibinder推遲綁定失敗GWT

[ERROR] [cricketscore] - Deferred binding failed for 'test.client.UserDashboard.MyUiBinder'; expect subsequent failures 

[ERROR] [cricketscore] - Unable to load module entry point class test.client.DashBoard (see associated exception for details). 

請幫我解決它的問題。

Cricketscore.gwt.xml

<?xml version="1.0" encoding="UTF-8"?> 
<!-- 
    When updating your version of GWT, you should also update this DTD reference, 
    so that your app can take advantage of the latest GWT module capabilities. 
--> 
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.0//EN" 
    "http://google-web-toolkit.googlecode.com/svn/tags/2.5.0/distro-source/core/src/gwt-module.dtd"> 
<module rename-to='cricketscore'> 
    <!-- Inherit the core Web Toolkit stuff.      --> 
    <inherits name='com.google.gwt.user.User'/> 

    <!-- Inherit the default GWT style sheet. You can change  --> 
    <!-- the theme of your GWT application by uncommenting   --> 
    <!-- any one of the following lines.       --> 
    <inherits name='com.google.gwt.user.theme.clean.Clean'/> 
    <!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> --> 
    <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> --> 
    <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/>  --> 

    <!-- Other module inherits          --> 

    <!-- Specify the app entry point class.       --> 
    <entry-point class='test.client.DashBoard'/> 

    <!-- Specify the paths for translatable code     --> 
    <source path='client'/> 
    <source path='shared'/> 

</module> 

Dashboard.java

package test.client; 

import com.google.gwt.core.client.EntryPoint; 
import com.google.gwt.user.client.ui.RootPanel; 

public class DashBoard implements EntryPoint{ 

    @Override 
    public void onModuleLoad() { 
     RootPanel.get().add(new UserDashboard()); 
    } 
} 

UserDashboard.ui.xml

<!-- UserDashboard.ui.xml --> 

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' 
    xmlns:g='urn:import:com.google.gwt.user.client.ui' 
    xmlns:my='urn:import:test.client' > 

    <g:HTMLPanel> 
    <my:CricketScores ui:field='scores' teamNames='AUS, SAF, WA, QLD, VIC'/> 
    </g:HTMLPanel> 
</ui:UiBinder> 

CricketScores.java

package test.client; 

import com.google.gwt.uibinder.client.UiConstructor; 
import com.google.gwt.user.client.ui.Composite; 


public class CricketScores extends Composite{ 

    public @UiConstructor CricketScores(String teamNames) { 
      this(teamNames.split("[, ]+")); 
     } 

    public CricketScores(String... teamNames) { 
     // TODO Auto-generated constructor stub 
    } 
} 

UserDashboard.java

package test.client; 

import com.google.gwt.core.client.GWT; 
import com.google.gwt.uibinder.client.UiBinder; 
import com.google.gwt.uibinder.client.UiFactory; 
import com.google.gwt.user.client.ui.Composite; 
import com.google.gwt.user.client.ui.Widget; 

public class UserDashboard extends Composite { 
     interface MyUiBinder extends UiBinder<Widget, UserDashboard>{} 
     private static final MyUiBinder uiBinder = GWT.create(MyUiBinder.class); 

     private final String[] teamNames; 

     public UserDashboard(String... teamNames) { 
     this.teamNames = teamNames; 
     initWidget(uiBinder.createAndBindUi(this)); 
     } 

     @UiFactory CricketScores makeCricketScores() { 
     return new CricketScores(teamNames); 
     } 
    } 
+2

和創建的各個組件的對象時,它得到了解決。「......相關的例外......」是什麼地方? – 2013-02-26 10:32:17

+0

例外的是在sun.reflect.NativeMethodAccessorImpl.invoke0(本機方法)在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java java.lang.reflect.InvocationTargetException :25)在com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:406)上com.google.gwt.dev上的java.lang.reflect.Method.invoke(Method.java:597)。 shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:5 – Mani 2013-02-26 10:41:54

+0

)是*整個*異常嗎?嘗試註釋掉'this(teamNames.split (「[,] +」));'在構造函數中。 – 2013-02-26 10:46:49

回答

2

衝突的在你的代碼信息:一個@UiConstructor@UiFactory(實際上沒有衝突的,有優先順序,但它也可能混淆開發人員,也就是你)。

UiBinder的會更喜歡@UiFactory@UiConstructor,你的工廠沒有任何說法,所以從你的XML的teamNames屬性暫定映射到setTeamNames setter,它不存在,因此「類CricketScores有沒有合適的setTeamNames()方法「錯誤。

的問題是在你的代碼的概念:你UserDashboard構建與它傳遞給CricketScores部件隊的名單,讓小部件不應該在一個XML屬性teamNames

+1

thanx男人....你知道任何網站的uifactory和uiconstructor除谷歌開發人員網站....他們給了非常對這些概念有限 – Mani 2013-02-26 11:43:46

0

我得到同樣的錯誤和uiField(提供=真)是越來越空,但是當我在構造函數中