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 <saharab...@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: saharab...@gmail.com, hmp.hau...@foxmail.com > website: http://haulynjason.net > gtalk: saharab...@gmail.com > skype: saharabear > QQ: 378606292 > > Haulyn Jason > -- Pedro Henrique Oliveira dos Santos