2

my custom widget look like below

public class CustomWidget extends Composite {

    public static CustomWidget wrap(com.google.gwt.dom.client.Element element) {

        assert Document.get().getBody().isOrHasChild(element);

        CustomWidget customWiget = new CustomWidget(element);//this line is still ok,customWidget has value

       customWiget.onAttach();//i get Caused by: java.lang.NullPointerException: null 
       RootPanel.detachOnWindowClose(customWiget);


        return button;
      }


protected CustomWidget(com.google.gwt.dom.client.Element element) {
        setElement(element);


}

}

is my wrap method correctly written? I get error at the point i commented

Element element = DOM.getElementById( object );
CustomWidget testKeyValue= CustomWidget.wrap(element);
cometta
  • 35,071
  • 77
  • 215
  • 324

1 Answers1

0

Please check that element != null after this line:

Element element = DOM.getElementById( object );

(Probably assertions are turned off, so your current code will only fail in onAttach().)

Community
  • 1
  • 1
Chris Lercher
  • 37,264
  • 20
  • 99
  • 131