I think onInitialize is playing the role of the Component#addNotify method
from awt framework. It is an useful callback to not root components, were
they can adjust their sate based on the existing component tree. And if we
rename it to onAddedToComponentTree or addNotify as in the awt framework?
After doing so we can even recreate the onInitialize method but as a
callback for an fully constructed component.
The problem about this idea is that we would end up increasing the API,
maybe without the need. Anyway I'm 1+ to delay the onInitialize call until
the first onConfigure call, because makes sense to provide an callback from
a more mature component state.

On Tue, Feb 1, 2011 at 2:52 PM, Igor Vaynberg <igor.vaynb...@gmail.com>wrote:

> apparently some people also use it as a post-construct callback, which
> sort of makes sense. for example, to call overridable factory methods,
> which you cannot do from the constructor.
>
> the solution is to delay all calls to oninitialize until just before
> the very first call to onconfigure. i have mixed feelings about it
> because essentially when instantiating a new page you get an
> incomplete/lazy-initialized object and it is hard to have any useful
> methods on it that configure it further.
>
> -igor
>
>
> On Tue, Feb 1, 2011 at 3:35 AM, Pedro Santos <pedros...@gmail.com> wrote:
> > onInitialize is only there to provide an place on the component code
> where
> > you can rely on a path to the page from the component. It is useless
> inside
> > an page.
> >
> > On Tue, Feb 1, 2011 at 9:25 AM, tetsuo <ronald.tet...@gmail.com> wrote:
> >
> >> Overriding onInitialize() on Pages certainly may cause some problems,
> >> if you mix adding components there and in constructors in the same
> >> class hierarchy, but it will work with some care. I'm using
> >> onInitialize() to build Pages, because, in the infrastructure already
> >> built in a project I'm working on, I have to instantiate Pages to
> >> determine if a link to it is enabled or not. I don't use its
> >> 'construction', I don't need components. I just instantiate it to call
> >> a method 'hasPermission()' on it.
> >>
> >> Well, please don't tell me I shouldn't do it, it works and works well.
> >> The only problem is that in 1.5 the method is final on Pages. Is there
> >> any workaround? Would you consider reverting this change? Or will I
> >> have to stay with 1.4 forever?
> >>
> >> Tetsuo
> >>
> >
> >
> >
> > --
> > Pedro Henrique Oliveira dos Santos
> >
>



-- 
Pedro Henrique Oliveira dos Santos

Reply via email to