Wednesday, August 1, 2012

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

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

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/Eiz5kKUyivAJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment