Thanks Igor. That did it. I knew it couldn't be that complicated.
-----Original Message----- From: Igor Vaynberg [mailto:[email protected]] Sent: Wednesday, October 28, 2009 11:16 PM To: [email protected] Subject: Re: Replacing a panel with another panel class mycomponent { component A; void onclick() { component B=new something(A.getId()); A.replaceWith(B); A=B; } } the "A=B" is what you are missing. -igor On Wed, Oct 28, 2009 at 7:06 PM, Jeffrey Schneller <[email protected]> wrote: > So how would I reference B rather than A on all subsequent calls after the > first. Is it as simple as checking to see if A does not have some property > set? Then just use an if/then/else statement to use the correct panel. > > Thanks. > > > > -----Original Message----- > From: Eelco Hillenius [mailto:[email protected]] > Sent: Wed 10/28/2009 6:20 PM > To: [email protected] > Subject: Re: Replacing a panel with another panel > >> I am trying to replace a panel with another panel. The replacement >> works the first time. The next time I click on the replacement link, I >> get an exception. >> >> "java.lang.IllegalStateException: This method can only be called on a >> component that has already been added to its parent." > > My guess is that you are referencing the the first panel again. When > you replace panel A with panel B, panel A loses it's reference to the > parent (which goes to B obviously), so if you were to replace on A > again, you get an exception like that. The solution is to reference B > rather than A. > > Eelco > > --------------------------------------------------------------------- > 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
