简单的 GWT 编辑器示例
我发现除了复制和粘贴现有的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您初始化编辑器驱动程序时,“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 editorinit
call.