4.8. Exploring the lifecycle of a widget

From a developer’s perspective, using a widget is easy. You create the widget and add it to your application via a panel. When you’re finished with the widget, you remove it from the panel (or remove the panel), and you’re done.

In the background, GWT is working hard on your behalf to link the Java view of the widget to the browser DOM’s view of the widget, to protect you from introducing memory leaks and circular references, and to clean up after you. All that makes your code less likely to mess up your users’ experience. GWT has a lifecycle for a widget, and we show that in figure 4.21.

Figure 4.21. The lifecycle stages of a GWT widget

Sometimes it’s useful to hook into GWT’s widget lifecycle—you ...

Get GWT in Action, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.