You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Will Jaynes <ja...@mail.umms.med.umich.edu> on 2007/08/10 13:51:48 UTC

getting component parent

Using 1.3. I have a panel which needs to create different internal 
components depending on who it's parent is. However, calling getParent() 
in the constructor gives me null. I can make a constuctor that passes in 
the parent. But I wonder if there is a different way. Is there some 
other point where I could call getParent(), get the parent, and then 
construct the components for the panel?

Will

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: getting component parent

Posted by Martijn Dashorst <ma...@gmail.com>.
Another option is to override onBeforeRender

The problem is that the component is not added to the parent in the
constructor yet:

add(new Foo());

First Foo constructor is called, then the add...

In your case, having an explicit contract about the parent isn't too
bad though. Gives an opportunity to document what happens when you add
it to a different component.

Martijn

On 8/10/07, Will Jaynes <ja...@mail.umms.med.umich.edu> wrote:
> Using 1.3. I have a panel which needs to create different internal
> components depending on who it's parent is. However, calling getParent()
> in the constructor gives me null. I can make a constuctor that passes in
> the parent. But I wonder if there is a different way. Is there some
> other point where I could call getParent(), get the parent, and then
> construct the components for the panel?
>
> Will
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Wicket joins the Apache Software Foundation as Apache Wicket
Apache Wicket 1.3.0-beta2 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta2/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org