# COSMOS Developer's Guide

### Widgets

As stated in previous sections, widgets are web components that can be assembled into a unified web console. COSMOS provides a set of out-of-the-box widgets that are outlined under the Web Component Library document. It is possible to extend the existing widgets or create new widgets using the Dojo toolkit. As a result the reader should be familiar with the Dojo widget library and life cycle of the Dojo widgets. It is assumed that the reader is familiar with creating and extending a widget based on the Dojo toolkit programming model.

Let us look at the life cycle of a widget within the COSMOS UI infrastructure when processing a page template.

1. The page template is processed and the COSMOS bootstrapping code is executed. Within this phase the Dojo and COSMOS javascript files are imported into the page.
2. Next an `org.eclipse.cosmos.provisional.dr.ps.components.utility.UIContext` class is instantiated. The UIContext object provides widget factory methods and other convenient methods to submit XML HTTP Requests.
3. Next the declared `org.eclipse.cosmos.provisional.dr.ps.components.widget.WidgetContainer`, within the page template, are created with their associated attachPoint names. During creating of the WidgetContainer object a call is made to the UIContext widget factory method to create and return all the widgets associated with the attachPoint name. It should be noted that each widget created via the factory methods will get a handle to the UIContext object. This allows these widgets to use the convenient methods provided by the UIContext class. The WidgetContainer then appends the newly created widget to its root DOM node resulting in the widget being rendered in the page.

[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]