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
<jeffrey.schnel...@envisa.com> 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:eelco.hillen...@gmail.com]
> Sent: Wed 10/28/2009 6:20 PM
> To: users@wicket.apache.org
> 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: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to