GWT简单的DockPanel使用错误

时间:2011-03-05 20:10:28

标签: java gwt uibinder dockpanel

为什么这个“代码”失败

<g:DockPanel unit="px">
    <g:south size="100">
        <g:TextBox ui:field="host" text="localhost"/>
    </g:south>
    <g:south size="100">
        <g:TextBox ui:field="port" text="3287"/>
    </g:south>
</g:DockPanel>

虽然这个

<g:HorizontalPanel>
    <g:cell>
        <g:TextBox ui:field="host" text="localhost"/>
    </g:cell>
    <g:cell>
        <g:TextBox ui:field="port" text="3287"/>
    </g:cell>
</g:HorizontalPanel>

其他信息:

栈跟踪

ERROR: Deferred binding failed for 'client.view.EnterPage.EnterPageUiBinder'; expect subsequent failures. 
ERROR: Unable to load module entry point class client.Dbweb (see associated exception for details). java.lang.RuntimeException: Deferred binding failed for 'client.view.EnterPage$EnterPageUiBinder' (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:98)
    at client.view.EnterPage.<clinit>(EnterPage.java:27)
    at client.Dbweb.onModuleLoad(Dbweb.java:15)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396)
    at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:183)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:510)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
    at java.lang.Thread.run(Thread.java:662)
Caused by: com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
    at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:595)
    at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:455)
    at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
    at com.google.gwt.core.client.GWT.create(GWT.java:98)
    at client.view.EnterPage.<clinit>(EnterPage.java:27)
    at client.Dbweb.onModuleLoad(Dbweb.java:15)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396)
    at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:183)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:510)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
    at java.lang.Thread.run(Thread.java:662)

创建活页夹

interface EnterPageUiBinder extends UiBinder<HTMLPanel, EnterPage> {
}

private static EnterPageUiBinder ourUiBinder = GWT.create(EnterPageUiBinder.class);

两个面板描述我将其包装成

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
         xmlns:g='urn:import:com.google.gwt.user.client.ui'>
    <g:HTMLPanel>
    panel description
    bla-bla
    </g:HTMLPanel>
</ui:UiBinder>

更新如果你遇到同样的问题,你可以去@Peter Knego的解决方案或做像smt一样

<g:DockLayoutPanel unit="PX">
      <g:south size="100">
          <g:TextBox ui:field="host" text="localhost"/>
      </g:south>
      <g:south size="100">
          <g:TextBox ui:field="port" text="3287"/>
      </g:south>
  </g:DockLayoutPanel>

2 个答案:

答案 0 :(得分:6)

如有疑问,请咨询the source

正确的布局是:

    <g:DockPanel>
        <g:Dock direction="SOUTH" size="100px">
            <g:TextBox text="localhost"/>
        </g:Dock>
        <g:Dock direction="SOUTH" size="100px">
            <g:TextBox text="3287"/>
        </g:Dock>
    </g:DockPanel>

答案 1 :(得分:2)

我不确定你的DockPanel中应该有两次南面板。而且我认为你现在应该使用DockLayoutPanel。