You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Haulyn R. Jason" <sa...@gmail.com> on 2009/09/27 03:24:01 UTC
confused about component parent field
Hi, all
I design a component for display a navigation bar with panel swap tech.
I define a Panel as the name of currentPanel and use DashboardPanel to
instance it., and define a List<Panel> to generate the navigation bar.
Other people will transfer the list to my component, and when the Link be
clicked, my component will execute these codes:
currentPanel.replaceWith(targetPanel);
currentPanel = targetPanel;
but I get the following error message:
WicketMessage: Method onLinkClicked of interface
org.apache.wicket.markup.html.link.ILinkListener targeted at component
[MarkupContainer [Component id = url]] threw an exception
Root cause:
java.lang.IllegalStateException: This method can only be called on a
component that has already been added to its parent.
I debug the application and I find there is a parent field in the
currentPanel, in the begining, the value of parent field is "Panel",
but parent field of targetPanel from the List<Panel> which is
transfered from other application is NULL.
I am confused on the parent field, who can tell me which part I forget
to use the panel swapping tech?
--
Many thanks!
Haulyn Microproduction
Mobile: +086-15864011231
email: saharabear@gmail.com, hmp.haulyn@foxmail.com
website: http://haulynjason.net
gtalk: saharabear@gmail.com
skype: saharabear
QQ: 378606292
Haulyn Jason
Re: confused about component parent field
Posted by "Haulyn R. Jason" <sa...@gmail.com>.
Hi, Pedro,
after debug, I found the problem, and I add this line before my code:
this.getParent().addOrReplace(currentPanel),
this line resolve the problem.
Thanks :)
On Mon, Sep 28, 2009 at 7:25 PM, Pedro Santos <pe...@gmail.com> wrote:
> Hi Haulyn, if you call
>
> currentPanel.replaceWith(targetPanel);
>
> an got
> java.lang.IllegalStateException: This method can only be called on a
> component that has already been added to its parent.
>
> the only thing that can cause that exception is: currentPanel hasn't an
> parent.
>
> Work direct with the parent when you swap panels, just to make sure you
> will
> not fall in that exception. You have a list of then right? Use:
> parent.replace(childChoicedOnListOfPanelToSwap)
>
> On Sat, Sep 26, 2009 at 10:24 PM, Haulyn R. Jason <saharabear@gmail.com
> >wrote:
>
> > Hi, all
> > I design a component for display a navigation bar with panel swap tech.
> > I define a Panel as the name of currentPanel and use DashboardPanel to
> > instance it., and define a List<Panel> to generate the navigation bar.
> > Other people will transfer the list to my component, and when the Link be
> > clicked, my component will execute these codes:
> >
> > currentPanel.replaceWith(targetPanel);
> > currentPanel = targetPanel;
> >
> > but I get the following error message:
> >
> > WicketMessage: Method onLinkClicked of interface
> > org.apache.wicket.markup.html.link.ILinkListener targeted at component
> > [MarkupContainer [Component id = url]] threw an exception
> >
> > Root cause:
> >
> > java.lang.IllegalStateException: This method can only be called on a
> > component that has already been added to its parent.
> >
> >
> > I debug the application and I find there is a parent field in the
> > currentPanel, in the begining, the value of parent field is "Panel",
> > but parent field of targetPanel from the List<Panel> which is
> > transfered from other application is NULL.
> >
> >
> > I am confused on the parent field, who can tell me which part I forget
> > to use the panel swapping tech?
> >
> >
> >
> > --
> > Many thanks!
> >
> > Haulyn Microproduction
> >
> > Mobile: +086-15864011231
> > email: saharabear@gmail.com, hmp.haulyn@foxmail.com
> > website: http://haulynjason.net
> > gtalk: saharabear@gmail.com
> > skype: saharabear
> > QQ: 378606292
> >
> > Haulyn Jason
> >
>
>
>
> --
> Pedro Henrique Oliveira dos Santos
>
--
Many thanks!
Haulyn Microproduction
Mobile: +086-15864011231
email: saharabear@gmail.com, hmp.haulyn@foxmail.com
website: http://haulynjason.net/
gtalk: saharabear@gmail.com
skype: saharabear
QQ: 378606292
Haulyn Jason
Re: confused about component parent field
Posted by Pedro Santos <pe...@gmail.com>.
Hi Haulyn, if you call
currentPanel.replaceWith(targetPanel);
an got
java.lang.IllegalStateException: This method can only be called on a
component that has already been added to its parent.
the only thing that can cause that exception is: currentPanel hasn't an
parent.
Work direct with the parent when you swap panels, just to make sure you will
not fall in that exception. You have a list of then right? Use:
parent.replace(childChoicedOnListOfPanelToSwap)
On Sat, Sep 26, 2009 at 10:24 PM, Haulyn R. Jason <sa...@gmail.com>wrote:
> Hi, all
> I design a component for display a navigation bar with panel swap tech.
> I define a Panel as the name of currentPanel and use DashboardPanel to
> instance it., and define a List<Panel> to generate the navigation bar.
> Other people will transfer the list to my component, and when the Link be
> clicked, my component will execute these codes:
>
> currentPanel.replaceWith(targetPanel);
> currentPanel = targetPanel;
>
> but I get the following error message:
>
> WicketMessage: Method onLinkClicked of interface
> org.apache.wicket.markup.html.link.ILinkListener targeted at component
> [MarkupContainer [Component id = url]] threw an exception
>
> Root cause:
>
> java.lang.IllegalStateException: This method can only be called on a
> component that has already been added to its parent.
>
>
> I debug the application and I find there is a parent field in the
> currentPanel, in the begining, the value of parent field is "Panel",
> but parent field of targetPanel from the List<Panel> which is
> transfered from other application is NULL.
>
>
> I am confused on the parent field, who can tell me which part I forget
> to use the panel swapping tech?
>
>
>
> --
> Many thanks!
>
> Haulyn Microproduction
>
> Mobile: +086-15864011231
> email: saharabear@gmail.com, hmp.haulyn@foxmail.com
> website: http://haulynjason.net
> gtalk: saharabear@gmail.com
> skype: saharabear
> QQ: 378606292
>
> Haulyn Jason
>
--
Pedro Henrique Oliveira dos Santos