You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by pe1er <fu...@gmail.com> on 2012/12/13 21:14:48 UTC
Wicket 6.3.0 AjaxLink: IAjaxCallListener behaviour
Prior to Wicket 6 the javascript code returned by
IAjaxCallDecorator.decorateScipt was executed immediately after a click. I
migrated IAjaxCallDecorator according to the migration-guide. By clicking 3
times the link within 5 seconds the expected result is:
getPrecondition
getPrecondition
getPrecondition
getSuccessHandler
getSuccessHandler
getSuccessHandler
But the result was:
getPrecondition
getSuccessHandler
getPrecondition
getSuccessHandler
getPrecondition
getSuccessHandler
Is there another way to migrate IAjaxCallDecorator to Wicket 6?
public class HomePage extends WebPage {
public HomePage(final PageParameters parameters) {
add(new Label("version",
getApplication().getFrameworkSettings().getVersion()));
AjaxLink<Void> blockingLink = new AjaxLink<Void>("blockingLink") {
@Override
public void onClick(AjaxRequestTarget target) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
IAjaxCallListener blockingListener = new AjaxCallListener() {
@Override
public CharSequence getPrecondition(Component component) {
return "console.log('getPrecondition');";
}
@Override
public CharSequence getSuccessHandler(Component component) {
return "console.log('getSuccessHandler');";
}
};
attributes.getAjaxCallListeners().add(blockingListener);
}
};
add(blockingLink);
}
}
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-6-3-0-AjaxLink-IAjaxCallListener-behaviour-tp4654785.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: Wicket 6.3.0 AjaxLink: IAjaxCallListener behaviour
Posted by pe1er <fu...@gmail.com>.
Hi,
Use case: Blocking until an Ajax request is complete see
http://my.safaribooksonline.com/book/-/9781849511605/deeper-into-ajax/ch07lvl1sec04
<http://my.safaribooksonline.com/book/-/9781849511605/deeper-into-ajax/ch07lvl1sec04>
(Page 162)
But you are right:
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
{
super.updateAjaxAttributes(attributes);
attributes.setChannel(new AjaxChannel("myChannel",
AjaxChannel.Type.ACTIVE));
}
did the job. Thank you!
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-6-3-0-AjaxLink-IAjaxCallListener-behaviour-tp4654785p4654804.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: Wicket 6.3.0 AjaxLink: IAjaxCallListener behaviour
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
You experience this behavior because there is a synchronization of the Ajax
requests at the client side - see AjaxChannel's javadoc.
What is your use case ?
On Thu, Dec 13, 2012 at 10:14 PM, pe1er <fu...@gmail.com> wrote:
> Prior to Wicket 6 the javascript code returned by
> IAjaxCallDecorator.decorateScipt was executed immediately after a click. I
> migrated IAjaxCallDecorator according to the migration-guide. By clicking 3
> times the link within 5 seconds the expected result is:
>
> getPrecondition
> getPrecondition
> getPrecondition
> getSuccessHandler
> getSuccessHandler
> getSuccessHandler
>
> But the result was:
>
> getPrecondition
> getSuccessHandler
> getPrecondition
> getSuccessHandler
> getPrecondition
> getSuccessHandler
>
> Is there another way to migrate IAjaxCallDecorator to Wicket 6?
>
> public class HomePage extends WebPage {
>
> public HomePage(final PageParameters parameters) {
> add(new Label("version",
> getApplication().getFrameworkSettings().getVersion()));
>
> AjaxLink<Void> blockingLink = new AjaxLink<Void>("blockingLink") {
> @Override
> public void onClick(AjaxRequestTarget target) {
> try {
> Thread.sleep(5000);
> } catch (InterruptedException e) {
> e.printStackTrace();
> }
> }
> @Override
> protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
> super.updateAjaxAttributes(attributes);
>
> IAjaxCallListener blockingListener = new AjaxCallListener() {
> @Override
> public CharSequence getPrecondition(Component component) {
> return "console.log('getPrecondition');";
> }
> @Override
> public CharSequence getSuccessHandler(Component component) {
> return "console.log('getSuccessHandler');";
> }
> };
> attributes.getAjaxCallListeners().add(blockingListener);
> }
> };
> add(blockingLink);
> }
> }
>
>
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-6-3-0-AjaxLink-IAjaxCallListener-behaviour-tp4654785.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
>
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>