You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Michael Wyraz <mi...@evermind.de> on 2014/07/23 15:46:24 UTC

Tracking ajax requests with T5.4

Hi,

I'd like to track ajax requests (when do they start, when they are 
finished) for some purposes:
1. Selenium UI tests - here I'd like to wait until ajax requests are 
finished befor a test continues
2. Dynamic busy pane

I found some idea how it can work at 
http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/loadingspinner
Unfortunately this won't work on T5.4. I had a deeper look to the code. 
It seems that no explicit event is triggered when an ajax request is 
started or ended. At least in dom.js a counter is increased/decreased 
but this is not exported and it is decreased before the request is 
processed - so not an ideal solution.

What would be the best way to hook into dom.ajaxRequest or alternatively 
in ajax.js? Or should we change it in tapestry to expose this 
information via dom events?

Kind regards,
Michael.


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


Re: Tracking ajax requests with T5.4

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 24 Jul 2014 08:53:40 -0300, Michael Wyraz  
<mi...@evermind.de> wrote:

> Hi Lance,
>
> this won't really help. I need to known when the ajax processing is  
> finished - not that a zone was updated (the fact, that there are zone  
> updates is not known to my script).

What do you mean by "ajax processing is finished"? The events Lance  
mentioned are only triggered after the AJAX request was finished,  
processed and the client-side DOM was updated. The global Prototype and  
jQuery AJAX handlers tell you when an AJAX request is started and when it  
finishes. Anything else is in your code and it's up to you to track it.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


Re: Tracking ajax requests with T5.4

Posted by Lance Java <la...@googlemail.com>.
Since tapestry 5.4 you can wait for the data-ajax-active attribute to be
"false" on the <body>

See SeleniumTestCase.waitForAjaxRequestsToComplete()

Re: Tracking ajax requests with T5.4

Posted by Michael Wyraz <mi...@evermind.de>.
Hi Lance,

this won't really help. I need to known when the ajax processing is 
finished - not that a zone was updated (the fact, that there are zone 
updates is not known to my script).

> Oops... That was for 5.3.
>
> Try this instead
>
> $(document).bind("t5:zone:did-update", function() {...})
> On 24 Jul 2014 11:15, "Lance Java" <la...@googlemail.com> wrote:
>
>> $(document).bind(Tapestry.ZONE_UPDATED_EVENT, function() {...})
>>   On 24 Jul 2014 10:22, "Michael Wyraz" <mi...@evermind.de> wrote:
>>
>>> Hi,
>>>
>>> unfortunately it works not completely as expected. The reason is that
>>> that jQuery event if fired when the response is received, not when the
>>> response is processed. So i have a race-contition here where tapestry is
>>> aplying zoneupdates or redirects but my script thinks that the request is
>>> already done.
>>> It looks that I explicitely need a hook to when tapestry is done
>>> processing the result.
>>>
>>> So again my question: what is the best way to extend dom.js? or do we
>>> need to add the event to the tapestry-core?
>>>
>>>
>>>   Hi Thiago,
>>>> thank you very much for the hint. Look that I searched at the wrong
>>>> place. I could solve my problem using the following script:
>>>>
>>>>     define(["jquery"],function($) {
>>>>          var ajaxCount=0;
>>>>          $(document).ajaxStart(function() {
>>>>              ajaxCount++;
>>>>              console.log("Ajax Start. Number of runing ajax requests:
>>>>     "+ajaxCount);
>>>>              document.ajaxRunning=ajaxCount>0;
>>>>          });
>>>>          $(document).ajaxStop(function() {
>>>>              ajaxCount--;
>>>>              console.log("Ajax Stop. Number of runing ajax requests:
>>>>     "+ajaxCount);
>>>>              document.ajaxRunning=ajaxCount>0;
>>>>          });
>>>>     });
>>>>
>>>> Plus a special "WebDriverWait"-Condition that checks this flag.
>>>>
>>>>
>>>>   On Wed, 23 Jul 2014 10:46:24 -0300, Michael Wyraz <
>>>>> michael.wyraz@evermind.de> wrote:
>>>>>
>>>>>   Hi,
>>>>> Hi!
>>>>>
>>>>>   I'd like to track ajax requests (when do they start, when they are
>>>>>> finished) for some purposes:
>>>>>>
>>>>> Both Prototype and jQuery provide callbacks for this.
>>>>>
>>>>>
>>>>
>>> --
>>>
>>> Mit freundlichen Grüßen / Kind regards
>>>
>>> Michael Wyraz
>>>
>>> evermind GmbH
>>> Schorlemmerstraße 1
>>> 04155 Leipzig
>>>
>>> Tel.:       +49 (0)341-25 39 66 - 0
>>> Fax:        +49 (0)341-25 39 66 - 1
>>> Funk:       +49 (0)177-73 00 00 3
>>> E-Mail:     michael.wyraz@evermind.de
>>>
>>> HRB: 21586
>>> Amtsgericht Leipzig
>>>
>>> Geschäftsführer:
>>> Christoph Klemm
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>


-- 

Mit freundlichen Grüßen / Kind regards

Michael Wyraz

evermind GmbH
Schorlemmerstraße 1
04155 Leipzig

Tel.:       +49 (0)341-25 39 66 - 0
Fax:        +49 (0)341-25 39 66 - 1
Funk:       +49 (0)177-73 00 00 3
E-Mail:     michael.wyraz@evermind.de

HRB: 21586
Amtsgericht Leipzig

Geschäftsführer:
Christoph Klemm


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


Re: Tracking ajax requests with T5.4

Posted by Lance Java <la...@googlemail.com>.
Oops... That was for 5.3.

Try this instead

$(document).bind("t5:zone:did-update", function() {...})
On 24 Jul 2014 11:15, "Lance Java" <la...@googlemail.com> wrote:

> $(document).bind(Tapestry.ZONE_UPDATED_EVENT, function() {...})
>  On 24 Jul 2014 10:22, "Michael Wyraz" <mi...@evermind.de> wrote:
>
>> Hi,
>>
>> unfortunately it works not completely as expected. The reason is that
>> that jQuery event if fired when the response is received, not when the
>> response is processed. So i have a race-contition here where tapestry is
>> aplying zoneupdates or redirects but my script thinks that the request is
>> already done.
>> It looks that I explicitely need a hook to when tapestry is done
>> processing the result.
>>
>> So again my question: what is the best way to extend dom.js? or do we
>> need to add the event to the tapestry-core?
>>
>>
>>  Hi Thiago,
>>>
>>> thank you very much for the hint. Look that I searched at the wrong
>>> place. I could solve my problem using the following script:
>>>
>>>    define(["jquery"],function($) {
>>>         var ajaxCount=0;
>>>         $(document).ajaxStart(function() {
>>>             ajaxCount++;
>>>             console.log("Ajax Start. Number of runing ajax requests:
>>>    "+ajaxCount);
>>>             document.ajaxRunning=ajaxCount>0;
>>>         });
>>>         $(document).ajaxStop(function() {
>>>             ajaxCount--;
>>>             console.log("Ajax Stop. Number of runing ajax requests:
>>>    "+ajaxCount);
>>>             document.ajaxRunning=ajaxCount>0;
>>>         });
>>>    });
>>>
>>> Plus a special "WebDriverWait"-Condition that checks this flag.
>>>
>>>
>>>  On Wed, 23 Jul 2014 10:46:24 -0300, Michael Wyraz <
>>>> michael.wyraz@evermind.de> wrote:
>>>>
>>>>  Hi,
>>>>>
>>>>
>>>> Hi!
>>>>
>>>>  I'd like to track ajax requests (when do they start, when they are
>>>>> finished) for some purposes:
>>>>>
>>>>
>>>> Both Prototype and jQuery provide callbacks for this.
>>>>
>>>>
>>>
>>>
>>
>> --
>>
>> Mit freundlichen Grüßen / Kind regards
>>
>> Michael Wyraz
>>
>> evermind GmbH
>> Schorlemmerstraße 1
>> 04155 Leipzig
>>
>> Tel.:       +49 (0)341-25 39 66 - 0
>> Fax:        +49 (0)341-25 39 66 - 1
>> Funk:       +49 (0)177-73 00 00 3
>> E-Mail:     michael.wyraz@evermind.de
>>
>> HRB: 21586
>> Amtsgericht Leipzig
>>
>> Geschäftsführer:
>> Christoph Klemm
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>

Re: Tracking ajax requests with T5.4

Posted by Lance Java <la...@googlemail.com>.
$(document).bind(Tapestry.ZONE_UPDATED_EVENT, function() {...})
 On 24 Jul 2014 10:22, "Michael Wyraz" <mi...@evermind.de> wrote:

> Hi,
>
> unfortunately it works not completely as expected. The reason is that that
> jQuery event if fired when the response is received, not when the response
> is processed. So i have a race-contition here where tapestry is aplying
> zoneupdates or redirects but my script thinks that the request is already
> done.
> It looks that I explicitely need a hook to when tapestry is done
> processing the result.
>
> So again my question: what is the best way to extend dom.js? or do we need
> to add the event to the tapestry-core?
>
>
>  Hi Thiago,
>>
>> thank you very much for the hint. Look that I searched at the wrong
>> place. I could solve my problem using the following script:
>>
>>    define(["jquery"],function($) {
>>         var ajaxCount=0;
>>         $(document).ajaxStart(function() {
>>             ajaxCount++;
>>             console.log("Ajax Start. Number of runing ajax requests:
>>    "+ajaxCount);
>>             document.ajaxRunning=ajaxCount>0;
>>         });
>>         $(document).ajaxStop(function() {
>>             ajaxCount--;
>>             console.log("Ajax Stop. Number of runing ajax requests:
>>    "+ajaxCount);
>>             document.ajaxRunning=ajaxCount>0;
>>         });
>>    });
>>
>> Plus a special "WebDriverWait"-Condition that checks this flag.
>>
>>
>>  On Wed, 23 Jul 2014 10:46:24 -0300, Michael Wyraz <
>>> michael.wyraz@evermind.de> wrote:
>>>
>>>  Hi,
>>>>
>>>
>>> Hi!
>>>
>>>  I'd like to track ajax requests (when do they start, when they are
>>>> finished) for some purposes:
>>>>
>>>
>>> Both Prototype and jQuery provide callbacks for this.
>>>
>>>
>>
>>
>
> --
>
> Mit freundlichen Grüßen / Kind regards
>
> Michael Wyraz
>
> evermind GmbH
> Schorlemmerstraße 1
> 04155 Leipzig
>
> Tel.:       +49 (0)341-25 39 66 - 0
> Fax:        +49 (0)341-25 39 66 - 1
> Funk:       +49 (0)177-73 00 00 3
> E-Mail:     michael.wyraz@evermind.de
>
> HRB: 21586
> Amtsgericht Leipzig
>
> Geschäftsführer:
> Christoph Klemm
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Tracking ajax requests with T5.4

Posted by Michael Wyraz <mi...@evermind.de>.
Hi,

unfortunately it works not completely as expected. The reason is that 
that jQuery event if fired when the response is received, not when the 
response is processed. So i have a race-contition here where tapestry is 
aplying zoneupdates or redirects but my script thinks that the request 
is already done.
It looks that I explicitely need a hook to when tapestry is done 
processing the result.

So again my question: what is the best way to extend dom.js? or do we 
need to add the event to the tapestry-core?


> Hi Thiago,
>
> thank you very much for the hint. Look that I searched at the wrong 
> place. I could solve my problem using the following script:
>
>    define(["jquery"],function($) {
>         var ajaxCount=0;
>         $(document).ajaxStart(function() {
>             ajaxCount++;
>             console.log("Ajax Start. Number of runing ajax requests:
>    "+ajaxCount);
>             document.ajaxRunning=ajaxCount>0;
>         });
>         $(document).ajaxStop(function() {
>             ajaxCount--;
>             console.log("Ajax Stop. Number of runing ajax requests:
>    "+ajaxCount);
>             document.ajaxRunning=ajaxCount>0;
>         });
>    });
>
> Plus a special "WebDriverWait"-Condition that checks this flag.
>
>
>> On Wed, 23 Jul 2014 10:46:24 -0300, Michael Wyraz 
>> <mi...@evermind.de> wrote:
>>
>>> Hi,
>>
>> Hi!
>>
>>> I'd like to track ajax requests (when do they start, when they are 
>>> finished) for some purposes:
>>
>> Both Prototype and jQuery provide callbacks for this.
>>
>
>


-- 

Mit freundlichen Grüßen / Kind regards

Michael Wyraz

evermind GmbH
Schorlemmerstraße 1
04155 Leipzig

Tel.:       +49 (0)341-25 39 66 - 0
Fax:        +49 (0)341-25 39 66 - 1
Funk:       +49 (0)177-73 00 00 3
E-Mail:     michael.wyraz@evermind.de

HRB: 21586
Amtsgericht Leipzig

Geschäftsführer:
Christoph Klemm


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


Re: Tracking ajax requests with T5.4

Posted by Michael Wyraz <mi...@evermind.de>.
Hi Thiago,

thank you very much for the hint. Look that I searched at the wrong 
place. I could solve my problem using the following script:

    define(["jquery"],function($) {
         var ajaxCount=0;
         $(document).ajaxStart(function() {
             ajaxCount++;
             console.log("Ajax Start. Number of runing ajax requests:
    "+ajaxCount);
             document.ajaxRunning=ajaxCount>0;
         });
         $(document).ajaxStop(function() {
             ajaxCount--;
             console.log("Ajax Stop. Number of runing ajax requests:
    "+ajaxCount);
             document.ajaxRunning=ajaxCount>0;
         });
    });

Plus a special "WebDriverWait"-Condition that checks this flag.


> On Wed, 23 Jul 2014 10:46:24 -0300, Michael Wyraz 
> <mi...@evermind.de> wrote:
>
>> Hi,
>
> Hi!
>
>> I'd like to track ajax requests (when do they start, when they are 
>> finished) for some purposes:
>
> Both Prototype and jQuery provide callbacks for this.
>


-- 

Mit freundlichen Grüßen / Kind regards

Michael Wyraz

evermind GmbH
Schorlemmerstraße 1
04155 Leipzig

Tel.:       +49 (0)341-25 39 66 - 0
Fax:        +49 (0)341-25 39 66 - 1
Funk:       +49 (0)177-73 00 00 3
E-Mail:     michael.wyraz@evermind.de

HRB: 21586
Amtsgericht Leipzig

Geschäftsführer:
Christoph Klemm


Re: Tracking ajax requests with T5.4

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 23 Jul 2014 10:46:24 -0300, Michael Wyraz  
<mi...@evermind.de> wrote:

> Hi,

Hi!

> I'd like to track ajax requests (when do they start, when they are  
> finished) for some purposes:

Both Prototype and jQuery provide callbacks for this.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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