简单的 GWT 编辑器示例

发布于 2024-11-05 07:09:35 字数 1588 浏览 8 评论 0原文

我发现除了复制和粘贴现有的 GWT 编辑器示例之外的任何事情都令人沮丧。这里尝试创建一个最小的编辑器,但没有成功。

public class ContactEditor extends Composite implements Editor<Contact> {

    interface Binder extends UiBinder<Widget, ContactEditor> {}

    interface ContactEditorDriver extends
        SimpleBeanEditorDriver<Contact, ContactEditor> {}
    private final ContactEditorDriver editorDriver;

    @UiField TextBox salutation;

    public ContactEditor(Contact contact) {
        editorDriver = GWT.create(ContactEditorDriver.class);
        editorDriver.initialize(this); 
        editorDriver.edit(contact);

        initWidget(GWT.<Binder> create(Binder.class).createAndBindUi(this));
    }
}

当用它实例化时,

ContactEditor contactEditor = new ContactEditor(new Contact());

我得到一个 UmbrellaException ,其中包含

Caused by: java.lang.NullPointerException: null
    at ...ContactEditor_SimpleBeanEditorDelegate.attachSubEditors(ContactEditor_SimpleBeanEditorDelegate.java:12)
    at com.google.gwt.editor.client.impl.AbstractEditorDelegate.initialize(AbstractEditorDelegate.java:264)
    at com.google.gwt.editor.client.impl.SimpleBeanEditorDelegate.initialize(SimpleBeanEditorDelegate.java:32)
    at com.google.gwt.editor.client.impl.AbstractSimpleBeanEditorDriver.edit(AbstractSimpleBeanEditorDriver.java:45)
    at ...ContactEditor.<init>(ContactEditor.java

这里发生了什么---SubEditors?失败似乎是在生成的代码中,我很难调试。

非常感谢。

I'm finding anything other than copying and pasting existing GWT Editor examples to be frustrating. Here's an attempt to create a minimal Editor, without success.

public class ContactEditor extends Composite implements Editor<Contact> {

    interface Binder extends UiBinder<Widget, ContactEditor> {}

    interface ContactEditorDriver extends
        SimpleBeanEditorDriver<Contact, ContactEditor> {}
    private final ContactEditorDriver editorDriver;

    @UiField TextBox salutation;

    public ContactEditor(Contact contact) {
        editorDriver = GWT.create(ContactEditorDriver.class);
        editorDriver.initialize(this); 
        editorDriver.edit(contact);

        initWidget(GWT.<Binder> create(Binder.class).createAndBindUi(this));
    }
}

When this is instantiated with

ContactEditor contactEditor = new ContactEditor(new Contact());

I get an UmbrellaException that contains

Caused by: java.lang.NullPointerException: null
    at ...ContactEditor_SimpleBeanEditorDelegate.attachSubEditors(ContactEditor_SimpleBeanEditorDelegate.java:12)
    at com.google.gwt.editor.client.impl.AbstractEditorDelegate.initialize(AbstractEditorDelegate.java:264)
    at com.google.gwt.editor.client.impl.SimpleBeanEditorDelegate.initialize(SimpleBeanEditorDelegate.java:32)
    at com.google.gwt.editor.client.impl.AbstractSimpleBeanEditorDriver.edit(AbstractSimpleBeanEditorDriver.java:45)
    at ...ContactEditor.<init>(ContactEditor.java

What's going on here---SubEditors? The failure seems to be in generated code and is hard for me to debug.

Much thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

女中豪杰 2024-11-12 07:09:35

当您初始化编辑器驱动程序时,“salutation”子编辑器尚未初始化(仍为 null)。

createAndBindUi 调用移至编辑器 init 调用之前。

By the time you initialize the editor driver, the "salutation" subeditor isn't initialized yet (still null).

Move your createAndBindUi call before the editor init call.

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