You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by ab...@orange-ftgroup.com on 2010/06/02 11:17:44 UTC

Override IAjaxIndicatorAware behavior

Hi all,

I use IAjaxIndicatorAware to display a div like a modal window 'please wait' when a javascript call is processing. I found this interface very usefull because it is simple to implement and the behavior is the same for all component in the web app that needs an indicator when processing ajax calls.

I would like to override this behavior to display the div only when an ajax call takes more than 2 seconds for example to be executed. So for a little ajax call less than 2 seconds, I would like that nothing appears.

I've seach solutions but I found nothing, how would you do that?

Thanks


Aurélie


Re: Override IAjaxIndicatorAware behavior

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Just an idea...

1-Use a flag on the client to control you are on an AJAX request (set
it at the begining and unset it at the end)
2-Combine this with a setTimeout(showMyAjaxVeil, 2000) and on
showMyAjaxVeil function see if this flag is still set and if so show
the div.
3-Hide the div at the end of the request and unset the flag.

I don't know if this might work neither if you will have some
"synchronization" issues.

Ernesto

On Wed, Jun 2, 2010 at 11:17 AM,  <ab...@orange-ftgroup.com> wrote:
> Hi all,
>
> I use IAjaxIndicatorAware to display a div like a modal window 'please wait' when a javascript call is processing. I found this interface very usefull because it is simple to implement and the behavior is the same for all component in the web app that needs an indicator when processing ajax calls.
>
> I would like to override this behavior to display the div only when an ajax call takes more than 2 seconds for example to be executed. So for a little ajax call less than 2 seconds, I would like that nothing appears.
>
> I've seach solutions but I found nothing, how would you do that?
>
> Thanks
>
>
> Aurélie
>
>

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


Re: Override IAjaxIndicatorAware behavior

Posted by Jeremy Thomerson <je...@wickettraining.com>.
See the previous response from Ernesto - he describes very well how to
accomplish this.

On Thu, Jun 3, 2010 at 1:59 AM, Aurelie Boiteux <
aboiteux.ext@orange-ftgroup.com> wrote:

>
> Yes, that's exactly what I did.
>
> My problem is that I want that div "veil" shows up only if an ajax call
> takes more than 2 seconds to process. If the ajax processing is short (less
> than 2 seconds), I don't want this div shows up.
> I don't know how to do it.
>
> Thanks
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Override-IAjaxIndicatorAware-behavior-tp2239813p2241266.html
> Sent from the Wicket - User 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
>
>


-- 
Jeremy Thomerson
http://www.wickettraining.com

Re: Override IAjaxIndicatorAware behavior

Posted by Aurelie Boiteux <ab...@orange-ftgroup.com>.
Yes, that's exactly what I did. 

My problem is that I want that div "veil" shows up only if an ajax call
takes more than 2 seconds to process. If the ajax processing is short (less
than 2 seconds), I don't want this div shows up.
I don't know how to do it.

Thanks
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Override-IAjaxIndicatorAware-behavior-tp2239813p2241266.html
Sent from the Wicket - User 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: Override IAjaxIndicatorAware behavior

Posted by Zilvinas Vilutis <ci...@gmail.com>.
As I understood per
http://wicketinaction.com/2008/12/preventing-double-ajax-requests-in-3-lines-of-code/-
you can make your BasePage implement that interface and all the app
should
use the same ajax indicator.

Please correct me if I'm wrong.

Žilvinas Vilutis

Mobile:   (+370) 652 38353
E-mail:   cikasfm@gmail.com


On Wed, Jun 2, 2010 at 8:40 AM, Aurelie Boiteux <
aboiteux.ext@orange-ftgroup.com> wrote:

>
> Hi,
>
> This solution works if I create a specific AjaxLink that implements
> IAjaxIndicatorAware, so I can specify the AjaxCallDecorator.
>
> But I implement the interface in a specific WebPage so div is displayed for
> each ajax call that occur in this page.
>
> I try to find a solution to override the behavior for every ajax call of a
> webPage that implements the interface of the entire application.
>
> Do you think it's possible?
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Override-IAjaxIndicatorAware-behavior-tp2239813p2240354.html
> Sent from the Wicket - User 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: Override IAjaxIndicatorAware behavior

Posted by Aurelie Boiteux <ab...@orange-ftgroup.com>.
Hi,

This solution works if I create a specific AjaxLink that implements
IAjaxIndicatorAware, so I can specify the AjaxCallDecorator.

But I implement the interface in a specific WebPage so div is displayed for
each ajax call that occur in this page.

I try to find a solution to override the behavior for every ajax call of a
webPage that implements the interface of the entire application.

Do you think it's possible?
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Override-IAjaxIndicatorAware-behavior-tp2239813p2240354.html
Sent from the Wicket - User 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: Override IAjaxIndicatorAware behavior

Posted by Wilhelmsen Tor Iver <To...@arrive.no>.
> I would like to override this behavior to display the div only when an
> ajax call takes more than 2 seconds for example to be executed. So for
> a little ajax call less than 2 seconds, I would like that nothing
> appears.

If you set the div initially invisible (display: none) you can add Javascript that triggers when the request is made with a two second timer (setTimeout) that then shows it, then in the Ajax response you cancel the timer.

e.g. in you AjaxCallDecorator.decorateScript():

return "var f = function() { getElementById('xxx').style.display='block' }; window.my_ajax_feedback = setTimeout(f, 2000);" + script;

and in the response you prepend

clearTimeout(window.my_ajax_feedback);

- Tor Iver

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