使用uibinder延迟绑定GWT失败
以下是项目中使用的全部文件。它给出了这些错误使用uibinder延迟绑定GWT失败,gwt,web,uibinder,toolkit,deferred,Gwt,Web,Uibinder,Toolkit,Deferred,以下是项目中使用的全部文件。它给出了这些错误 [ERROR] [cricketscore] - Deferred binding failed for 'test.client.UserDashboard.MyUiBinder'; expect subsequent failures 及 请帮我解决其中的问题 Cricketscore.gwt.xml <?xml version="1.0" encoding="UTF-8"?> <!-- When updating you
[ERROR] [cricketscore] - Deferred binding failed for 'test.client.UserDashboard.MyUiBinder'; expect subsequent failures
及
请帮我解决其中的问题
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>
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>
UserDashboard.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());
}
}
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);
}
}
package test.client;
导入com.google.gwt.core.client.gwt;
导入com.google.gwt.uibinder.client.uibinder;
导入com.google.gwt.uibinder.client.UiFactory;
导入com.google.gwt.user.client.ui.Composite;
导入com.google.gwt.user.client.ui.Widget;
公共类UserDashboard扩展了复合{
接口MyUiBinder扩展了UiBinder{}
私有静态final MyUiBinder=GWT.create(MyUiBinder.class);
私有最终字符串[]团队名称;
公共UserDashboard(字符串…团队名称){
this.teamNames=团队名称;
initWidget(uiBinder.createAndBindUi(this));
}
@UiFactory CricketScores MakeCicketScores(){
返回新的板球得分(球队名称);
}
}
您的代码中有冲突的信息:一个@UiConstructor
和一个@UiFactory
(实际上并不冲突,有一个优先顺序,但这可能会让开发人员(即您)感到困惑)
UiBinder更喜欢@UiFactory
而不是@UiConstructor
,并且您的工厂没有参数,因此XML中的teamNames
属性暂时映射到一个settamnames
setter,该setter不存在,因此“类没有合适的settamnames()方法”错误
问题在代码中是概念性的:您的
UserDashboard
是用一个团队名称列表构建的,它传递给CricketScores
小部件,因此小部件在XML中不应该有teamNames
属性。我得到了相同的错误和uiField(提供=true)正在获取null,但在我在构造函数中创建相应组件的对象时得到解决,“…关联的异常…”在哪里?异常是sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)在sun.reflect.NativeMethodAccessorImpl.invoke的java.lang.reflect.InvokeTargetException(NativeMethodAccessorImpl.java:39)在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)在java.lang.reflect.Method.invoke(Method.java:597)在com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:406)在com.google.gwt.dev.shell.oophSessionHandler.loadModule(oophSessionHandler.java:200)上在com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:5这是整个异常吗?请尝试在构造函数中注释this(teamNames.split([,]+);
)。请运行编译(而不是DevMode)为获得更好的例外情况,请使用完整日志更新您的问题。Rebinding test.client.UserDashboard.MyUiBinder调用generator com.google.gwt.uibinder.rebind.UiBinderGenerator[ERROR]类没有合适的settamNames()方法:(:8)[ERROR ERROR]在'test/client/UserDashboard.java'中出现错误[ERROR]第13行:无法通过延迟绑定[WARN]解析“test.client.UserDashboard.MyUiBinder”。对于以下类型,从未提交生成的源(是否忘记调用commit()?)[WARN]test.client.UserDashboard\u MyUiBinderImplthanx man…除了谷歌开发者网站之外,你知道uifactory和uiconstructor的任何网站吗…他们对这些概念给出的信息非常有限
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
}
}
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);
}
}