如何从 UiBinder 描述 GXT Window?

发布于 2024-12-27 09:23:58 字数 637 浏览 4 评论 0原文

我有一个简单的 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 元素中添加 Test 时,出现错误:

[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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷情妓 2025-01-03 09:23:58

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 under gxt:Window, since there's no element parser for any of the gxt:Window superclasses. GWT's Panels extend GWT's HasWidgets and there's an element parser for them: HasWidgetsParser, which calls add() 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文