如何从 UiBinder 描述 GXT Window?
我有一个简单的 gxt 窗口:
public class MainWindow extends Window {
public MainWindow() {
Label test = new Label("Test");
add(test);
}
}
我想从 UiBinder 描述相同的窗口。这段代码工作完美:
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:gxt="urn:import:com.extjs.gxt.ui.client.widget">
<gxt:Window>
</gxt:Window>
</ui:UiBinder>
但是当我在 gxt:Window 元素中添加
时,出现错误:
[ERROR] Found unexpected child element Element <gxt:Label>
我做错了什么? Window 元素期望什么?
I have a simple gxt window:
public class MainWindow extends Window {
public MainWindow() {
Label test = new Label("Test");
add(test);
}
}
And I want to describe the same window from UiBinder. This code work perfectly:
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:gxt="urn:import:com.extjs.gxt.ui.client.widget">
<gxt:Window>
</gxt:Window>
</ui:UiBinder>
But when I add <gxt:Label>Test</gxt:Label>
in gxt:Window element I have error:
[ERROR] Found unexpected child element Element <gxt:Label>
What I do wrong? What expected in Window element?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Ext GWT 2.x 不支持 UiBinder(原因是缺少在 GWT 中创建自定义元素解析器的公共 API:http://code.google.com/p/google-web-toolkit/issues/detail?id=4461)。
您可以添加组件
gxt:Windows
但仅此而已,您无法在gxt:Window
下添加子元素,因为任何 gxt:Window 都没有元素解析器超类。 GWT 的面板扩展了 GWT 的HasWidgets
,并且有一个针对它们的元素解析器:HasWidgetsParser,它调用为每个子元素添加add()
。可以解决这个问题,我想这就是他们所做的 Ext GWT 3 beta 因为它声称“完全支持 UiBinder”,所以你可以尝试一下。
Ext GWT 2.x doesn't support UiBinder (the reason being the absence of public API to create custom element parsers in GWT: http://code.google.com/p/google-web-toolkit/issues/detail?id=4461).
You can add a component
gxt:Windows
but that's it, you can't add child elements undergxt:Window
, since there's no element parser for any of the gxt:Window superclasses. GWT's Panels extend GWT'sHasWidgets
and there's an element parser for them: HasWidgetsParser, which callsadd()
for each child element.It's possible to workaround this and I guess that's what they've done for Ext GWT 3 beta since it claims "full UiBinder support", so you can try that.