Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple GWT Editor Example

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.

like image 612
Glenn Avatar asked Jul 13 '26 02:07

Glenn


1 Answers

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.

like image 102
Thomas Broyer Avatar answered Jul 15 '26 01:07

Thomas Broyer