what's the matter between the constructor and the onloud method

33 views
Skip to first unread message

wahaha

unread,
Aug 1, 2012, 4:05:03 AM8/1/12
to google-we...@googlegroups.com
i have written a customer-defined-widget, and it occur an error.
so i debuged it, the construtor run well, but before it gone to the "onload" method, it occur an error.
i want to ask that what does GWT do between the construtor and the "onload" method ?

wahaha

unread,
Aug 1, 2012, 4:05:41 AM8/1/12
to google-we...@googlegroups.com
sorry for my poor english

Joseph Lust

unread,
Aug 1, 2012, 10:16:04 AM8/1/12
to google-we...@googlegroups.com
In the widget lifecycle it starts with creation in the constructor, then injection into the DOM (attached), and then loaded. The UiBinder can call the constructor on its own, or you can pass it in (provided=true). Depending on what type of widget you're using (UiRenderer or UiBinder) the HTML string is created by GWT in the browser and then inserted into the destination node of the DOM. In some cases, where references are needed (i.e. UiField), temporary id's are inserted into the DOM and then removed to get this reference (why you can't us id's in UiBinder). Once all of this is complete the object is 'attached' and the eponymous event is fired. Then, directly after this onLoad() is fired. Later, when the widget is being removed, the detach event is fired.

The process is more complex than the above, but I hope if provides some clarity.


constructor
Object is created.

onAttach
This method is called when a widget is attached to the browser's document. To receive notification after a Widget has been added to the document, override the onLoad() method.

onLoad
This method is called immediately after a widget becomes attached to the browser's document.

Sincerely,
Joseph
Reply all
Reply to author
Forward
0 new messages