Great. Thx.
I also "resolved" this problem by using the constructor that takes
model as the second argument.
It seems both approaches remove encapsulation. i.e. The parent must
know ahead of time that child needs the handle to the model, and must
provide explicitly.
Is there any drawback (in terms of performance, resource usage, etc)
for providing the model to the child regardless it needs it or not?
--JY
On Dec 12, 2007 2:59 PM, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> add(new Label("label") {
> protected IModel initModel() { return getParent().getModel(); }
> });
>
> -igor
>
>
> On Dec 12, 2007 2:21 PM, jy <[EMAIL PROTECTED]> wrote:
> > Hello.
> >
> > A newbie here.
> > Is there a way for a child component to get access to the model added
> > to the parent component? I have two labels in the child component
> > that use the same model field. Since each label requires unique id, I
> > can't use CompoundPropertyModel, can i? I saw the example with
> > BoundCompoundPropertyModel, but that needs access to the model. So
> > how can i get the model that was added to the parent?
> >
> > I stepped into child component in debugger. Both getParent() and
> > getModel() return null.
> >
> > Thanks in advance,
> > J
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]