9 Feb 2009 2:08 AM #1
Initialization in View
In the View javadoc it is said :
/** * Called once prior to handleEvent being called. Widgets should be * instantiated in the init method rather than the view constructor. */
10 Feb 2009 6:15 AM #2
Maybe an answer :
Suppose you have a controller which has a lot of views. The first time the controller handles an event, the intialize() method is called. If all your views are instantiated in the initialize() method and you instantiate the widgets in the View constructor, then all the widgets of all the views will be instantiated (instead of being lazily).
18 Feb 2009 6:55 AM #3
18 Feb 2009 9:45 PM #4
I believe the current setup makes sense as it allows you to build your view (with LayoutContainers and such) and use your Controller to populate it's data. The data might change, but the view construction is unlikely to.
27 Feb 2009 12:13 AM #5
Anyway, even if you instantiate widgets in the initialize() method rather than constructor : once the widgets are instanciated, they will never be removed from memory.
If you create new widgets on each app event, they will not be kept in memory.