1
<?xml version="1.0" encoding="UTF-8"?>
<!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'>

    <ui:with field='res' type='com.myproject.resources.Resources'/>

    <ui:style>
        .panel {
            background-color: ivory;
        }
    </ui:style>

    <g:FlowPanel styleName='{style.panel}'>
        <g:Image url='{res.logo}'/>
        <g:VerticalPanel>
            <g:PushButton text="My Button" ui:field="myButton"></g:PushButton>
        </g:VerticalPanel>
    </g:FlowPanel>
</ui:UiBinder>

リソースクラスがあります

public interface  Resources extends ClientBundle {
      public static final Resources INSTANCE =  GWT.create(Resources.class);

      @Source("logo.png")
      ImageResource logo();


}

GWT XML エディターでエラーは発生しませんが、GWT デザイナーは読み込まれません。実行すると、例外も発生します。

onModuleLoad() threw an exception
Exception while loading module com.myproject.client.MyProject. See Development Mode for details.

java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396)
    at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Deferred binding failed for 'com.myproject.client.ClientFactory' (did you forget to inherit a required module?)
    at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:53)
    at com.google.gwt.core.client.GWT.create(GWT.java:97)
    at com.myproject.client.MyProject.onModuleLoad(MyProject.java:42)
    ... 9 more
Caused by: com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
    at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:503)
    at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
    ... 11 more
4

2 に答える 2

2

あなたが発行したものかどうかを判断するのは難しいですが、コードは次のようになります。

<g:Image resource='{res.logo}'/>

(つまりresource、そうではないurl)

于 2012-06-19T12:42:18.417 に答える
1

gwt.xml ファイルにこの inherits タグがあることを確認してください。これは、ClientBundle を使用するときに必要です。

<inherits name="com.google.gwt.resources.Resources" />
于 2012-06-19T13:29:55.237 に答える