You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by tomask79 <to...@embedit.cz> on 2015/04/15 10:03:31 UTC

Veil on ajax which ends with redirect eventually

Hi guys,

in our wicket application we use standard framework mechanism for showing
veil on Ajax actions by implementing the interface IAjaxIndicatorAware. It's
working fine until you've got situation when your onXXXX event method of
Ajax form component, for example, ends with setResponsePage redirect.
Something like this, typical scenario:

public void onXXXX(final AjaxRequestTarget target) {
    if (conditionForRerender) {
        target.add(...components...);
    } else {
       .....
       setResponsePage(MyClass, MyPageParams);
    }
}

Problem is when final action of onXXXX method is redirect then our user see
the blocking veil just when Ajax works and not until the redirect is
done...:-(. It's because redirect isn't ajax, wicket does redirection to
result in that case.

The solution which I can come up with is not using the interface
IAjaxIndicatorAware and manipulate the veil manually by leaving the veil
shown even after ajax process, eventual redirect will render new page so the
veil will be removed by redirection. 

Anyway, I would prefer if *framework could take care of it*. Something like
this would be awesome:

public void onXXXX(final AjaxRequestTarget target) {
    if (conditionForRerender) {
        target.add(...components...);
    } else {
       .....
       *target.setLeaveVeilOpen(true);*
       setResponsePage(MyClass, MyPageParams);
    }
}

which would add into to ajax response information: "Do not hide ajax
indicator"....So the redirection will be veiled as well.

Guys, please any suggestions to this?

Best Regards

Tomas

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Veil-on-ajax-which-ends-with-redirect-eventually-tp4670309.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: Veil on ajax which ends with redirect eventually

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Wicket hides the Ajax indicator at onComplete() callback [1].
The redirect is handled either at [2], [3] or [4]. All of those are
processed in the same "thread" (there is no usage of setTimeout()) so I
think the redirect should happen before the removal of the Ajax indicator.
I guess the loading of the new page takes some time and during that time
the JS of the current page is fully executed and that's why you see the old
page without the veil for some time.
I think it is OK to leave the veil (ajax indicator) in case of redirect for
all cases. We can just raise a flag in JS when a redirect is "scheduled".
Let's see what others think.
File a ticket for improvement at our JIRA.

1.
https://github.com/apache/wicket/blob/f2bc2ba0985352c44a416f9174f01e88e87f53e5/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js#L699
2.
https://github.com/apache/wicket/blob/f2bc2ba0985352c44a416f9174f01e88e87f53e5/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js#L769
3.
https://github.com/apache/wicket/blob/f2bc2ba0985352c44a416f9174f01e88e87f53e5/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js#L793
4.
https://github.com/apache/wicket/blob/f2bc2ba0985352c44a416f9174f01e88e87f53e5/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js#L1241

Martin Grigorov
Freelancer, available for hire!
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Wed, Apr 15, 2015 at 11:03 AM, tomask79 <to...@embedit.cz> wrote:

> Hi guys,
>
> in our wicket application we use standard framework mechanism for showing
> veil on Ajax actions by implementing the interface IAjaxIndicatorAware.
> It's
> working fine until you've got situation when your onXXXX event method of
> Ajax form component, for example, ends with setResponsePage redirect.
> Something like this, typical scenario:
>
> public void onXXXX(final AjaxRequestTarget target) {
>     if (conditionForRerender) {
>         target.add(...components...);
>     } else {
>        .....
>        setResponsePage(MyClass, MyPageParams);
>     }
> }
>
> Problem is when final action of onXXXX method is redirect then our user see
> the blocking veil just when Ajax works and not until the redirect is
> done...:-(. It's because redirect isn't ajax, wicket does redirection to
> result in that case.
>
> The solution which I can come up with is not using the interface
> IAjaxIndicatorAware and manipulate the veil manually by leaving the veil
> shown even after ajax process, eventual redirect will render new page so
> the
> veil will be removed by redirection.
>
> Anyway, I would prefer if *framework could take care of it*. Something like
> this would be awesome:
>
> public void onXXXX(final AjaxRequestTarget target) {
>     if (conditionForRerender) {
>         target.add(...components...);
>     } else {
>        .....
>        *target.setLeaveVeilOpen(true);*
>        setResponsePage(MyClass, MyPageParams);
>     }
> }
>
> which would add into to ajax response information: "Do not hide ajax
> indicator"....So the redirection will be veiled as well.
>
> Guys, please any suggestions to this?
>
> Best Regards
>
> Tomas
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Veil-on-ajax-which-ends-with-redirect-eventually-tp4670309.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
>
>