Tim Larson wrote:
A little context first: I was working with the union widget and decided to change the case id lookup to use lookupWidget(path) so it could reference widgets at other levels in the widget tree ("../../somewidget".) While implementing this I found that this lookup needs to happen after all the setParent(widget) calls have happened (after the widget tree has been fully built) or the lookup can fail.
Because widgets are not currently notified when tree building is finished, there was no place to plug in this lookupWidget() call, so I added initialize() to the Widget interface and added code to the form manager, AbstractContainerWidget, etc. to propagate a notification so I would have a place to initialize union widgets.
Now I realize I could have instead used a lazy lookup when the
case widget is first referenced, and I wonder if I should strip
out the initialize() code or if it would help a use case anyone
else has. WDYT?
I started implementing an "on-create" event listener, but failed on that same problem, as the whole form must be in a consistent state before that event can be fired, because the event listener can potentially reference any other widget.
So your initialize() stuff could be a solution to finish the implementation of create-event. However, that event must also be fired when a widget is creater later during the life for the form, e.g. when a new repeater row is created. So initialize() must also be called in that case.
Sylvain
-- Sylvain Wallez Anyware Technologies http://www.apache.org/~sylvain http://www.anyware-tech.com { XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
