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 <[email protected]> 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 <[email protected]
> >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: [email protected], [email protected]
> > website: http://haulynjason.net
> > gtalk: [email protected]
> > skype: saharabear
> > QQ: 378606292
> >
> > Haulyn Jason
> >
>
>
>
> --
> Pedro Henrique Oliveira dos Santos
>



-- 
Many thanks!

Haulyn Microproduction

Mobile: +086-15864011231
email: [email protected], [email protected]
website: http://haulynjason.net/
gtalk: [email protected]
skype: saharabear
QQ: 378606292

Haulyn Jason

Reply via email to