Simple GWT Editor Example

I find something else besides copying and pasting existing GWT editor examples to upset. Here is 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 is it created using

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

I get UmbrellaExceptioncontaining

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 is going on here - SubEditors? The error seems to be in the generated code and it's hard for me to debug.

Many thanks.

+3
source share
1 answer

By the time you initialize the editor driver, the “welcome” sub-editor is not yet initialized (yet null).

Move the call createAndBindUibefore calling the editor init.

+4
source

All Articles