Reputation: 9649
Is it safe to conclude the basic relationships among GWT panels and widgets below?
Upvotes: 1
Views: 1243
Reputation: 3671
Here's GWT hierarchy:
A panel is also a widget. Panels are widgets which can contain other widgets and panels. In generally they are used for layout and only rarely have data associated with them directly - the DisclosurePanel for example, can have data in the header, and the TabPanel's tabs. Some are based on an HTML table
element(e.g. HorizontalPanel) and some are based on the tag div
.
RootPanel is the panel to which contains other widgets. This panel is at the top of the containment hierarchy. The default it wraps tag body
of the host-page. RootPanel can contain any number of widgets, which will be laid out in their natural HTML ordering.
See docs.
Upvotes: 2
Reputation: 18331
Every GWT Widget instance has an element (reachable by calling getElement()
), and panels are just a kind of Widget - they still have a base element. Most Widgets build more content to do their work (for example: CheckBox is a span
with both an input
and a label
), and panels may need more than one element as well.
Widgets are appended to other widgets not just because this is how the DOM needs to be arranged, but also to track attaching and detaching widgets from the DOM. Among other things, this makes it possible to wire up event handlers only when actually attached, and unwire them when no longer part of the page.
RootPanel is a special widget that represents existing elements, either the body itself, or an element with a given ID. There may be more than one RootPanel, but they should not be nested. (That said, there may only be exactly one RootLayoutPanel, a sort of specialized RootPanel that also handles passing browser size information to child layout panels).
This may be the same idea that you were after, but I wanted to clarify that a Widget is frequently more than a single DOM node.
Upvotes: 2