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
Use case: Blocking until an Ajax request is complete see http://my.safaribooksonline.com/book/-/9781849511605/deeper-into-ajax/ch07lvl1sec04 (Page 162)
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);
}
}
Use case: Blocking until an Ajax request is complete see http://my.safaribooksonline.com/book/-/9781849511605/deeper-into-ajax/ch07lvl1sec04
(Page 162)
did the job. see wicket forum