【问题标题】:Simple GWT Editor Example简单的 GWT 编辑器示例
【发布时间】:2011-05-07 00:05:37
【问题描述】:

除了复制和粘贴现有的 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

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

非常感谢。

【问题讨论】:

    标签: gwt gwt2 gwt-editors


    【解决方案1】:

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

    将您的 createAndBindUi 呼叫移到编辑器 init 呼叫之前。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多