Suppose we've the following structure of widgets / panels in a GWT application -
- A Tree menu in the left of the DockLayoutPanel which is used for navigation to different applications.
- A panel in the center of the DockLayoutPanel and different content widgets getting loaded in this panel (this is controlled by the navigation tree menu.
- These content widgets are composites containing one or more widgets.
One way to deal with such application is to keep singletons for all widgets / panels, which means composites will hold singletons to all of their child widgets. But I feel this is excess usage of singleton. The other alternative is to construct new Widget object every time one is needed, but this must be expensive.
What are the best practices around this? Are there any standard patterns which take care of this problem?