Each widget is managed by the app container (framework) and has its own life cycle. When the app loads or users click a button, one or more widgets load and open. For the on-screen widgets, the layout manager asks the widget manager to load the widget in an asynchronous process. After the widget loads, the layout manager calls the setPosition method of the widget to append it to the DOM tree, places it in the right position, and allows the widget manager to open it. The following diagrams demonstrate how the methods are invoked regarding the widget life cycle.
The setPosition method is invoked to append the widget to the DOM tree and put the widget in the correct position. It only applies for the off-panel widget. For the in-panel widget, the widget's position is handled by the panel.
If the app is launched outside the builder's environment, the widget will not be destroyed once it is loaded. In the builder's environment, the widget is destroyed and re-created when the user configures the widget.
Each widget has two properties to store its widget state: state and windowState. The state property represents the widget's life state with three values: active, opened, and closed. The windowState property represents the widget's window state with three values as well: normal, maximized, and minimized. The following diagram shows the state changes:
- For the Dojo state, see Understanding_WidgetBase.
- To change the widget's state and windowState properties, use the methods from WidgetManager class.
- With the opened state, the widget is not active. When the widget is closed, it is not removed from the DOM tree; instead, it is hidden.
- For the windowState property, some widgets may have one or two states only.