You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alex66955 <ba...@googlemail.com> on 2012/07/31 16:44:41 UTC

ComponentNotFoundException when replace a fragment

Hey,

I have some issues when I replace a fragment in an ajax calback function.
There is a parent class and a child class. The parent create an
AbstractAjaxTimerBehavior and call in it the fragment with the child class.
In the child class there is also an AbstractAjaxTimerBehavior to process
some data to show. When I replace in the parent class ajax callback function
the fragment, I get the follow exception "ComponentNotFoundException". 

I think the child ajax request search for the right component, but the
component is replaced. How can I tell wicket that the component is no more
valid or something else.

My stack trace:






Best regards

Alex




--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/ComponentNotFoundException-when-replace-a-fragment-tp4650898.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: ComponentNotFoundException when replace a fragment

Posted by Bertrand Guay-Paquet <be...@step.polymtl.ca>.
Filed WICKET-4689.

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


Re: ComponentNotFoundException when replace a fragment

Posted by Martin Grigorov <mg...@apache.org>.
Yes.
Wicket sends a message on topic '/dom/node/removed' for each removed element.
Using its id we can stop the timer.
Please file the ticket :-)

On Wed, Aug 1, 2012 at 6:20 PM, Bertrand Guay-Paquet
<be...@step.polymtl.ca> wrote:
> Would this work if done on the client?
>
> New code when ajax response is received :
> replacedDOMElement = ...;
> $replacedDOMElement  = $(replacedDOMElement);
> for each js timers:
>     $component = $(timer.component);
>     if( $replacedDOMElement.is($component) ||
>         $replacedDOMElement.find($component ).length ) {
>
>         cancelTimer(timer);
>
>     }
>
> On 01/08/2012 10:37 AM, Martin Grigorov wrote:
>>
>> I see.
>> I'm not sure how Wicket can detect this situation ...
>>
>> A workaround would require some coding from the developer - when he
>> replaces the component he has to call additionally:
>> timerBehavior.stop(target).
>> This will clear the scheduled timeout in the browser.
>>
>> On Wed, Aug 1, 2012 at 5:31 PM, Bertrand Guay-Paquet
>> <be...@step.polymtl.ca> wrote:
>>>
>>> Yes I was using -beta3 since this is what Alex used. I just tried it with
>>> -SNAPSHOT (commit b89909c1fa99ae6973c3fb0738a966eb23c27e73) and I get the
>>> same exception.
>>>
>>> You say that:
>>>
>>>
>>> The precondition checks that the component (html element) on which is
>>> attached the timer behavior is still in the DOM document.
>>>
>>>
>>> In this case, the component id is still in the DOM (it was replaced by
>>> another one by the same id). The problem is that on the java side, the
>>> component is different and does not have a timer behavior attached, hence
>>> the callback fails.
>>>
>>>
>>> On 01/08/2012 10:14 AM, Martin Grigorov wrote:
>>>>
>>>> Do you use -beta3 ?
>>>> There was a bug which is fixed in -SNAPSHOT. That's why I know how it
>>>> works ;-)
>>>>
>>>> On Wed, Aug 1, 2012 at 5:12 PM, Bertrand Guay-Paquet
>>>> <be...@step.polymtl.ca> wrote:
>>>>>
>>>>> On 01/08/2012 9:58 AM, Martin Grigorov wrote:
>>>>>>
>>>>>>
>>>>>> No.
>>>>>> The timer is fired but the precondition prevents the Ajax call.
>>>>>> The precondition checks that the component (html element) on which is
>>>>>> attached the timer behavior is still in the DOM document.
>>>>>
>>>>> Hmm... I don't quite know what to say! In my tests, the timer is still
>>>>> fired
>>>>> event after its attached component is replaced.
>>>>>
>>>>> Here is the sequence of requests captured in Firebug:
>>>>>
>>>>> Ajax Request 1 (timer callback):
>>>>>
>>>>> http://localhost:8080/?2-1.IBehaviorListener.0-fragments&_=1343829988777
>>>>> <ajax-response>
>>>>> <evaluate>Wicket.timerHandle_fragments3 =
>>>>>
>>>>>
>>>>> setTimeout('Wicket.Ajax.ajax({\"u\":\"./.?2-1.IBehaviorListener.0-fragments\",\"c\":\"fragments3\"});',
>>>>> 2000)</evaluate>
>>>>> </ajax-response>
>>>>>
>>>>> Ajax Request 2 (click ajax link to replace the component "fragments"):
>>>>> http://localhost:8080/?2-1.IBehaviorListener.0-remove&_=1343829990235
>>>>> <ajax-response>
>>>>> <componentid="fragments3"><span wicket:id="fragments"
>>>>> id="fragments3">WMC</span></component>
>>>>> </ajax-response>
>>>>>
>>>>> Ajax Request 3 (timer callback):
>>>>>
>>>>> http://localhost:8080/?2-1.IBehaviorListener.0-fragments&_=1343829990803
>>>>> Throws exception:
>>>>> org.apache.wicket.behavior.InvalidBehaviorIdException: Cannot find
>>>>> behavior
>>>>> with id '0' on component
>>>>> 'org.apache.wicket.markup.html.WebMarkupContainer:fragments' in page
>>>>> '[Page
>>>>> class = com.mycompany.HomePage, id = 2, render count = 1]'. Perhaps the
>>>>> behavior did not properly implement getStatelessHint() and returned
>>>>> 'true'
>>>>> to indicate that it is stateless instead of returning 'false' to
>>>>> indicate
>>>>> that it is stateful.
>>>>>
>>>>> (this is a different exception than reported by Alex, but it looks like
>>>>> the
>>>>> same symptom)
>>>>>
>>>>> IMHO, the AjaxTimerBehavior should have been removed during the request
>>>>> #2
>>>>> since the replacement component does not have it attached.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: ComponentNotFoundException when replace a fragment

Posted by Bertrand Guay-Paquet <be...@step.polymtl.ca>.
Would this work if done on the client?

New code when ajax response is received :
replacedDOMElement = ...;
$replacedDOMElement  = $(replacedDOMElement);
for each js timers:
     $component = $(timer.component);
     if( $replacedDOMElement.is($component) ||
         $replacedDOMElement.find($component ).length ) {

         cancelTimer(timer);
     }

On 01/08/2012 10:37 AM, Martin Grigorov wrote:
> I see.
> I'm not sure how Wicket can detect this situation ...
>
> A workaround would require some coding from the developer - when he
> replaces the component he has to call additionally:
> timerBehavior.stop(target).
> This will clear the scheduled timeout in the browser.
>
> On Wed, Aug 1, 2012 at 5:31 PM, Bertrand Guay-Paquet
> <be...@step.polymtl.ca> wrote:
>> Yes I was using -beta3 since this is what Alex used. I just tried it with
>> -SNAPSHOT (commit b89909c1fa99ae6973c3fb0738a966eb23c27e73) and I get the
>> same exception.
>>
>> You say that:
>>
>>
>> The precondition checks that the component (html element) on which is
>> attached the timer behavior is still in the DOM document.
>>
>>
>> In this case, the component id is still in the DOM (it was replaced by
>> another one by the same id). The problem is that on the java side, the
>> component is different and does not have a timer behavior attached, hence
>> the callback fails.
>>
>>
>> On 01/08/2012 10:14 AM, Martin Grigorov wrote:
>>> Do you use -beta3 ?
>>> There was a bug which is fixed in -SNAPSHOT. That's why I know how it
>>> works ;-)
>>>
>>> On Wed, Aug 1, 2012 at 5:12 PM, Bertrand Guay-Paquet
>>> <be...@step.polymtl.ca> wrote:
>>>> On 01/08/2012 9:58 AM, Martin Grigorov wrote:
>>>>>
>>>>> No.
>>>>> The timer is fired but the precondition prevents the Ajax call.
>>>>> The precondition checks that the component (html element) on which is
>>>>> attached the timer behavior is still in the DOM document.
>>>> Hmm... I don't quite know what to say! In my tests, the timer is still
>>>> fired
>>>> event after its attached component is replaced.
>>>>
>>>> Here is the sequence of requests captured in Firebug:
>>>>
>>>> Ajax Request 1 (timer callback):
>>>> http://localhost:8080/?2-1.IBehaviorListener.0-fragments&_=1343829988777
>>>> <ajax-response>
>>>> <evaluate>Wicket.timerHandle_fragments3 =
>>>>
>>>> setTimeout('Wicket.Ajax.ajax({\"u\":\"./.?2-1.IBehaviorListener.0-fragments\",\"c\":\"fragments3\"});',
>>>> 2000)</evaluate>
>>>> </ajax-response>
>>>>
>>>> Ajax Request 2 (click ajax link to replace the component "fragments"):
>>>> http://localhost:8080/?2-1.IBehaviorListener.0-remove&_=1343829990235
>>>> <ajax-response>
>>>> <componentid="fragments3"><span wicket:id="fragments"
>>>> id="fragments3">WMC</span></component>
>>>> </ajax-response>
>>>>
>>>> Ajax Request 3 (timer callback):
>>>> http://localhost:8080/?2-1.IBehaviorListener.0-fragments&_=1343829990803
>>>> Throws exception:
>>>> org.apache.wicket.behavior.InvalidBehaviorIdException: Cannot find
>>>> behavior
>>>> with id '0' on component
>>>> 'org.apache.wicket.markup.html.WebMarkupContainer:fragments' in page
>>>> '[Page
>>>> class = com.mycompany.HomePage, id = 2, render count = 1]'. Perhaps the
>>>> behavior did not properly implement getStatelessHint() and returned
>>>> 'true'
>>>> to indicate that it is stateless instead of returning 'false' to indicate
>>>> that it is stateful.
>>>>
>>>> (this is a different exception than reported by Alex, but it looks like
>>>> the
>>>> same symptom)
>>>>
>>>> IMHO, the AjaxTimerBehavior should have been removed during the request
>>>> #2
>>>> since the replacement component does not have it attached.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>


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


Re: ComponentNotFoundException when replace a fragment

Posted by Martin Grigorov <mg...@apache.org>.
I see.
I'm not sure how Wicket can detect this situation ...

A workaround would require some coding from the developer - when he
replaces the component he has to call additionally:
timerBehavior.stop(target).
This will clear the scheduled timeout in the browser.

On Wed, Aug 1, 2012 at 5:31 PM, Bertrand Guay-Paquet
<be...@step.polymtl.ca> wrote:
> Yes I was using -beta3 since this is what Alex used. I just tried it with
> -SNAPSHOT (commit b89909c1fa99ae6973c3fb0738a966eb23c27e73) and I get the
> same exception.
>
> You say that:
>
>
> The precondition checks that the component (html element) on which is
> attached the timer behavior is still in the DOM document.
>
>
> In this case, the component id is still in the DOM (it was replaced by
> another one by the same id). The problem is that on the java side, the
> component is different and does not have a timer behavior attached, hence
> the callback fails.
>
>
> On 01/08/2012 10:14 AM, Martin Grigorov wrote:
>>
>> Do you use -beta3 ?
>> There was a bug which is fixed in -SNAPSHOT. That's why I know how it
>> works ;-)
>>
>> On Wed, Aug 1, 2012 at 5:12 PM, Bertrand Guay-Paquet
>> <be...@step.polymtl.ca> wrote:
>>>
>>> On 01/08/2012 9:58 AM, Martin Grigorov wrote:
>>>>
>>>>
>>>> No.
>>>> The timer is fired but the precondition prevents the Ajax call.
>>>> The precondition checks that the component (html element) on which is
>>>> attached the timer behavior is still in the DOM document.
>>>
>>> Hmm... I don't quite know what to say! In my tests, the timer is still
>>> fired
>>> event after its attached component is replaced.
>>>
>>> Here is the sequence of requests captured in Firebug:
>>>
>>> Ajax Request 1 (timer callback):
>>> http://localhost:8080/?2-1.IBehaviorListener.0-fragments&_=1343829988777
>>> <ajax-response>
>>> <evaluate>Wicket.timerHandle_fragments3 =
>>>
>>> setTimeout('Wicket.Ajax.ajax({\"u\":\"./.?2-1.IBehaviorListener.0-fragments\",\"c\":\"fragments3\"});',
>>> 2000)</evaluate>
>>> </ajax-response>
>>>
>>> Ajax Request 2 (click ajax link to replace the component "fragments"):
>>> http://localhost:8080/?2-1.IBehaviorListener.0-remove&_=1343829990235
>>> <ajax-response>
>>> <componentid="fragments3"><span wicket:id="fragments"
>>> id="fragments3">WMC</span></component>
>>> </ajax-response>
>>>
>>> Ajax Request 3 (timer callback):
>>> http://localhost:8080/?2-1.IBehaviorListener.0-fragments&_=1343829990803
>>> Throws exception:
>>> org.apache.wicket.behavior.InvalidBehaviorIdException: Cannot find
>>> behavior
>>> with id '0' on component
>>> 'org.apache.wicket.markup.html.WebMarkupContainer:fragments' in page
>>> '[Page
>>> class = com.mycompany.HomePage, id = 2, render count = 1]'. Perhaps the
>>> behavior did not properly implement getStatelessHint() and returned
>>> 'true'
>>> to indicate that it is stateless instead of returning 'false' to indicate
>>> that it is stateful.
>>>
>>> (this is a different exception than reported by Alex, but it looks like
>>> the
>>> same symptom)
>>>
>>> IMHO, the AjaxTimerBehavior should have been removed during the request
>>> #2
>>> since the replacement component does not have it attached.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: ComponentNotFoundException when replace a fragment

Posted by Bertrand Guay-Paquet <be...@step.polymtl.ca>.
Yes I was using -beta3 since this is what Alex used. I just tried it 
with -SNAPSHOT (commit b89909c1fa99ae6973c3fb0738a966eb23c27e73) and I 
get the same exception.

You say that:

The precondition checks that the component (html element) on which is
attached the timer behavior is still in the DOM document.


In this case, the component id is still in the DOM (it was replaced by 
another one by the same id). The problem is that on the java side, the 
component is different and does not have a timer behavior attached, 
hence the callback fails.

On 01/08/2012 10:14 AM, Martin Grigorov wrote:
> Do you use -beta3 ?
> There was a bug which is fixed in -SNAPSHOT. That's why I know how it works ;-)
>
> On Wed, Aug 1, 2012 at 5:12 PM, Bertrand Guay-Paquet
> <be...@step.polymtl.ca> wrote:
>> On 01/08/2012 9:58 AM, Martin Grigorov wrote:
>>>
>>> No.
>>> The timer is fired but the precondition prevents the Ajax call.
>>> The precondition checks that the component (html element) on which is
>>> attached the timer behavior is still in the DOM document.
>> Hmm... I don't quite know what to say! In my tests, the timer is still fired
>> event after its attached component is replaced.
>>
>> Here is the sequence of requests captured in Firebug:
>>
>> Ajax Request 1 (timer callback):
>> http://localhost:8080/?2-1.IBehaviorListener.0-fragments&_=1343829988777
>> <ajax-response>
>> <evaluate>Wicket.timerHandle_fragments3 =
>> setTimeout('Wicket.Ajax.ajax({\"u\":\"./.?2-1.IBehaviorListener.0-fragments\",\"c\":\"fragments3\"});',
>> 2000)</evaluate>
>> </ajax-response>
>>
>> Ajax Request 2 (click ajax link to replace the component "fragments"):
>> http://localhost:8080/?2-1.IBehaviorListener.0-remove&_=1343829990235
>> <ajax-response>
>> <componentid="fragments3"><span wicket:id="fragments"
>> id="fragments3">WMC</span></component>
>> </ajax-response>
>>
>> Ajax Request 3 (timer callback):
>> http://localhost:8080/?2-1.IBehaviorListener.0-fragments&_=1343829990803
>> Throws exception:
>> org.apache.wicket.behavior.InvalidBehaviorIdException: Cannot find behavior
>> with id '0' on component
>> 'org.apache.wicket.markup.html.WebMarkupContainer:fragments' in page '[Page
>> class = com.mycompany.HomePage, id = 2, render count = 1]'. Perhaps the
>> behavior did not properly implement getStatelessHint() and returned 'true'
>> to indicate that it is stateless instead of returning 'false' to indicate
>> that it is stateful.
>>
>> (this is a different exception than reported by Alex, but it looks like the
>> same symptom)
>>
>> IMHO, the AjaxTimerBehavior should have been removed during the request #2
>> since the replacement component does not have it attached.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>


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


Re: ComponentNotFoundException when replace a fragment

Posted by Martin Grigorov <mg...@apache.org>.
Do you use -beta3 ?
There was a bug which is fixed in -SNAPSHOT. That's why I know how it works ;-)

On Wed, Aug 1, 2012 at 5:12 PM, Bertrand Guay-Paquet
<be...@step.polymtl.ca> wrote:
> On 01/08/2012 9:58 AM, Martin Grigorov wrote:
>>
>>
>> No.
>> The timer is fired but the precondition prevents the Ajax call.
>> The precondition checks that the component (html element) on which is
>> attached the timer behavior is still in the DOM document.
>
> Hmm... I don't quite know what to say! In my tests, the timer is still fired
> event after its attached component is replaced.
>
> Here is the sequence of requests captured in Firebug:
>
> Ajax Request 1 (timer callback):
> http://localhost:8080/?2-1.IBehaviorListener.0-fragments&_=1343829988777
> <ajax-response>
> <evaluate>Wicket.timerHandle_fragments3 =
> setTimeout('Wicket.Ajax.ajax({\"u\":\"./.?2-1.IBehaviorListener.0-fragments\",\"c\":\"fragments3\"});',
> 2000)</evaluate>
> </ajax-response>
>
> Ajax Request 2 (click ajax link to replace the component "fragments"):
> http://localhost:8080/?2-1.IBehaviorListener.0-remove&_=1343829990235
> <ajax-response>
> <componentid="fragments3"><span wicket:id="fragments"
> id="fragments3">WMC</span></component>
> </ajax-response>
>
> Ajax Request 3 (timer callback):
> http://localhost:8080/?2-1.IBehaviorListener.0-fragments&_=1343829990803
> Throws exception:
> org.apache.wicket.behavior.InvalidBehaviorIdException: Cannot find behavior
> with id '0' on component
> 'org.apache.wicket.markup.html.WebMarkupContainer:fragments' in page '[Page
> class = com.mycompany.HomePage, id = 2, render count = 1]'. Perhaps the
> behavior did not properly implement getStatelessHint() and returned 'true'
> to indicate that it is stateless instead of returning 'false' to indicate
> that it is stateful.
>
> (this is a different exception than reported by Alex, but it looks like the
> same symptom)
>
> IMHO, the AjaxTimerBehavior should have been removed during the request #2
> since the replacement component does not have it attached.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: ComponentNotFoundException when replace a fragment

Posted by Bertrand Guay-Paquet <be...@step.polymtl.ca>.
On 01/08/2012 9:58 AM, Martin Grigorov wrote:
>
> No.
> The timer is fired but the precondition prevents the Ajax call.
> The precondition checks that the component (html element) on which is
> attached the timer behavior is still in the DOM document.
Hmm... I don't quite know what to say! In my tests, the timer is still 
fired event after its attached component is replaced.

Here is the sequence of requests captured in Firebug:

Ajax Request 1 (timer callback):
http://localhost:8080/?2-1.IBehaviorListener.0-fragments&_=1343829988777
<ajax-response>
<evaluate>Wicket.timerHandle_fragments3 = 
setTimeout('Wicket.Ajax.ajax({\"u\":\"./.?2-1.IBehaviorListener.0-fragments\",\"c\":\"fragments3\"});', 
2000)</evaluate>
</ajax-response>

Ajax Request 2 (click ajax link to replace the component "fragments"):
http://localhost:8080/?2-1.IBehaviorListener.0-remove&_=1343829990235
<ajax-response>
<componentid="fragments3"><span wicket:id="fragments" 
id="fragments3">WMC</span></component>
</ajax-response>

Ajax Request 3 (timer callback):
http://localhost:8080/?2-1.IBehaviorListener.0-fragments&_=1343829990803
Throws exception:
org.apache.wicket.behavior.InvalidBehaviorIdException: Cannot find 
behavior with id '0' on component 
'org.apache.wicket.markup.html.WebMarkupContainer:fragments' in page 
'[Page class = com.mycompany.HomePage, id = 2, render count = 1]'. 
Perhaps the behavior did not properly implement getStatelessHint() and 
returned 'true' to indicate that it is stateless instead of returning 
'false' to indicate that it is stateful.

(this is a different exception than reported by Alex, but it looks like 
the same symptom)

IMHO, the AjaxTimerBehavior should have been removed during the request 
#2 since the replacement component does not have it attached.

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


Re: ComponentNotFoundException when replace a fragment

Posted by Martin Grigorov <mg...@apache.org>.
On Wed, Aug 1, 2012 at 4:55 PM, Bertrand Guay-Paquet
<be...@step.polymtl.ca> wrote:
> Hi Alex,
>
> I tried your code and stripped it down as much as possible and couldn't find
> anything wrong with it. My guess is that Wicket ajax does not remove timers
> from replaced components in ajax responses. Therefore, the javascript
> timeout function is still executed on the client even if its related
> component is removed from the page.

No.
The timer is fired but the precondition prevents the Ajax call.
The precondition checks that the component (html element) on which is
attached the timer behavior is still in the DOM document.

>
> Please file a JIRA issue. I suggest using the simpler version below as a
> quickstart:
>
> HomePage.html
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <html xmlns:wicket="http://wicket.apache.org">
> <body>
>     <a href="#" wicket:id="remove">Replace the panel with attached time
> behavior</a><br>
>     <span wicket:id="fragments">WMC</span>
> </body>
> </html>
>
> HomePage.java
> import org.apache.log4j.Logger;
> import org.apache.wicket.Component;
> import org.apache.wicket.util.time.Duration;
> import org.apache.wicket.ajax.AbstractAjaxTimerBehavior;
> import org.apache.wicket.ajax.AjaxRequestTarget;
> import org.apache.wicket.ajax.markup.html.AjaxLink;
> import org.apache.wicket.markup.html.WebMarkupContainer;
> import org.apache.wicket.markup.html.WebPage;
>
> public class HomePage extends WebPage {
>     private static final Logger LOGGER = Logger.getLogger(HomePage.class);
>     private static final String TIMER_COMPONENT_ID = "fragments";
>
>     public HomePage() {
>         Component fragment = new WebMarkupContainer(TIMER_COMPONENT_ID);
>         fragment.add(new AbstractAjaxTimerBehavior(Duration.seconds(2)) {
>             @Override
>             protected void onTimer(AjaxRequestTarget target) {
>                 LOGGER.error("Timeout");
>             }
>         });
>         add(fragment.setOutputMarkupId(true));
>
>         add(new AjaxLink("remove") {
>             @Override
>             public void onClick(AjaxRequestTarget target) {
>                 Component fragment = new
> WebMarkupContainer(TIMER_COMPONENT_ID);
>                 HomePage.this.replace(fragment);
>                 target.add(fragment);
>             }
>         });
>     }
> }
>
> Bertrand
>
>
>
> On 01/08/2012 3:34 AM, Alex66955 wrote:
>>
>> TestParent.java
>>
>>
>> TestParent.html
>>
>>
>> TestChild.java
>>
>>
>> TestChild.html
>>
>>
>> Output:
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/ComponentNotFoundException-when-replace-a-fragment-with-ajax-tp4650898p4650909.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: ComponentNotFoundException when replace a fragment

Posted by Bertrand Guay-Paquet <be...@step.polymtl.ca>.
Hi Alex,

I tried your code and stripped it down as much as possible and couldn't 
find anything wrong with it. My guess is that Wicket ajax does not 
remove timers from replaced components in ajax responses. Therefore, the 
javascript timeout function is still executed on the client even if its 
related component is removed from the page.

Please file a JIRA issue. I suggest using the simpler version below as a 
quickstart:

HomePage.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:wicket="http://wicket.apache.org">
<body>
     <a href="#" wicket:id="remove">Replace the panel with attached time 
behavior</a><br>
     <span wicket:id="fragments">WMC</span>
</body>
</html>

HomePage.java
import org.apache.log4j.Logger;
import org.apache.wicket.Component;
import org.apache.wicket.util.time.Duration;
import org.apache.wicket.ajax.AbstractAjaxTimerBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.WebPage;

public class HomePage extends WebPage {
     private static final Logger LOGGER = Logger.getLogger(HomePage.class);
     private static final String TIMER_COMPONENT_ID = "fragments";

     public HomePage() {
         Component fragment = new WebMarkupContainer(TIMER_COMPONENT_ID);
         fragment.add(new AbstractAjaxTimerBehavior(Duration.seconds(2)) {
             @Override
             protected void onTimer(AjaxRequestTarget target) {
                 LOGGER.error("Timeout");
             }
         });
         add(fragment.setOutputMarkupId(true));

         add(new AjaxLink("remove") {
             @Override
             public void onClick(AjaxRequestTarget target) {
                 Component fragment = new 
WebMarkupContainer(TIMER_COMPONENT_ID);
                 HomePage.this.replace(fragment);
                 target.add(fragment);
             }
         });
     }
}

Bertrand


On 01/08/2012 3:34 AM, Alex66955 wrote:
> TestParent.java
>
>
> TestParent.html
>
>
> TestChild.java
>
>
> TestChild.html
>
>
> Output:
>
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/ComponentNotFoundException-when-replace-a-fragment-with-ajax-tp4650898p4650909.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


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


Re: ComponentNotFoundException when replace a fragment

Posted by Alex66955 <ba...@googlemail.com>.
TestParent.java


TestParent.html


TestChild.java


TestChild.html


Output:




--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/ComponentNotFoundException-when-replace-a-fragment-with-ajax-tp4650898p4650909.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: ComponentNotFoundException when replace a fragment

Posted by Bertrand Guay-Paquet <be...@step.polymtl.ca>.
With the stack trace, I can only see that the listener (the object 
responsible for handling a request) 
component"mainContentFragmens:eagrPanel" is not found in the current page.

Perhaps someone else can answer with only this but I would need code 
snippets showing how you manipulate your component tree.

On 31/07/2012 12:12 PM, Alex66955 wrote:
> Sorry.
> In the wicket user forum the stack trace is shown (perhaps the RAW-TAG).
>
> I use wicket 6.0.0-beta3
>
> trace:
> Last cause: Could not find component 'mainContentFragmens:eagrPanel' on page
> 'class com.vipco.spracherweiterung.CurrentDisplayPage
>
> org.apache.wicket.core.request.handler.ComponentNotFoundException: Could not
> find component 'mainContentFragmens:eagrPanel' on page 'class
> com.vipco.spracherweiterung.CurrentDisplayPage
>       at
> org.apache.wicket.core.request.handler.PageAndComponentProvider.getComponent(PageAndComponentProvider.java:182)
>       at
> org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.getComponent(ListenerInterfaceRequestHandler.java:90)
>       at
> org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:231)
>       at
> org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:814)
>       at
> org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
>       at
> org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:253)
>       at
> org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:210)
>       at
> org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:281)
>       at
> org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:188)
>       at
> org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:245)
>       at
> org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1326)
>       at
> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:479)
>       at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
>       at
> org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:520)
>       at
> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
>       at
> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:940)
>       at
> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:409)
>       at
> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
>       at
> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:874)
>       at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
>       at
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
>       at org.eclipse.jetty.server.Server.handle(Server.java:349)
>       at
> org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:441)
>       at
> org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:904)
>       at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:565)
>       at
> org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:217)
>       at
> org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:50)
>       at
> org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:245)
>       at
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
>       at
> org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
>       at java.lang.Thread.run(Thread.java:722)
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/ComponentNotFoundException-when-replace-a-fragment-with-ajax-tp4650898p4650902.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


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


Re: ComponentNotFoundException when replace a fragment

Posted by Alex66955 <ba...@googlemail.com>.
Sorry.
In the wicket user forum the stack trace is shown (perhaps the RAW-TAG). 

I use wicket 6.0.0-beta3

trace:
Last cause: Could not find component 'mainContentFragmens:eagrPanel' on page
'class com.vipco.spracherweiterung.CurrentDisplayPage

org.apache.wicket.core.request.handler.ComponentNotFoundException: Could not
find component 'mainContentFragmens:eagrPanel' on page 'class
com.vipco.spracherweiterung.CurrentDisplayPage
     at
org.apache.wicket.core.request.handler.PageAndComponentProvider.getComponent(PageAndComponentProvider.java:182)
     at
org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.getComponent(ListenerInterfaceRequestHandler.java:90)
     at
org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:231)
     at
org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:814)
     at
org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
     at
org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:253)
     at
org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:210)
     at
org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:281)
     at
org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:188)
     at
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:245)
     at
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1326)
     at
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:479)
     at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
     at
org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:520)
     at
org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
     at
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:940)
     at
org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:409)
     at
org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
     at
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:874)
     at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
     at
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
     at org.eclipse.jetty.server.Server.handle(Server.java:349)
     at
org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:441)
     at
org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:904)
     at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:565)
     at
org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:217)
     at
org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:50)
     at
org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:245)
     at
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
     at
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
     at java.lang.Thread.run(Thread.java:722)



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/ComponentNotFoundException-when-replace-a-fragment-with-ajax-tp4650898p4650902.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: ComponentNotFoundException when replace a fragment

Posted by Bertrand Guay-Paquet <be...@step.polymtl.ca>.
Hi Alex,

Your stack trace did not show up on the mailing list. Please also show a 
snippet showing what throws the exception.

Bertrand

On 31/07/2012 10:44 AM, Alex66955 wrote:
> Hey,
>
> I have some issues when I replace a fragment in an ajax calback function.
> There is a parent class and a child class. The parent create an
> AbstractAjaxTimerBehavior and call in it the fragment with the child class.
> In the child class there is also an AbstractAjaxTimerBehavior to process
> some data to show. When I replace in the parent class ajax callback function
> the fragment, I get the follow exception "ComponentNotFoundException".
>
> I think the child ajax request search for the right component, but the
> component is replaced. How can I tell wicket that the component is no more
> valid or something else.
>
> My stack trace:
>
>
>
>
>
>
> Best regards
>
> Alex
>
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/ComponentNotFoundException-when-replace-a-fragment-tp4650898.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


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