3
在Wicket 6之前,單擊後立即執行由IAjaxCallDecorator.decorateScipt返回的JavaScript代碼。我根據migration-guide遷移了IAjaxCallDecorator。 點擊3次節5秒內預期的結果是:Wicket 6.3.0 AjaxLink:IAjaxCallListener行爲
- getPrecondition
- getPrecondition
- getPrecondition
- getSuccessHandler
- getSuccessHandler
- getSuccessHandler
但結果是:
- getPrecondition
- getSuccessHandler
- getPrecondition
- getSuccessHandler
- getPrecondition
- getSuccessHandler
使用案例:阻塞,直到一個Ajax請求完成看http://my.safaribooksonline.com/book/-/9781849511605/deeper-into-ajax/ch07lvl1sec04(頁162 )
是否有另一種方法將IAjaxCallDecorator遷移到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);
}
}
AFAICS在調用進入隊列之前,沒有調用*的方法。你需要做什麼? – svenmeier
阻塞,直到Ajax請求完成請參閱http://my.safaribooksonline.com/book/-/9781849511605/deeper-into-ajax/ch07lvl1sec04 – user1518456