Gwt widget reset method

my custom widget looks 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 transfer method written correctly? I get an error at the point that I commented on

 Element element = DOM.getElementById( object ); CustomWidget testKeyValue= CustomWidget.wrap(element); 
+2
source share
1 answer

Please check that element != null after this line:

 Element element = DOM.getElementById( object ); 

(The statements are probably disabled , so your current code will only work on onAttach ().)

0
source

Source: https://habr.com/ru/post/1335712/


All Articles