问题描述
AjaxEventBehavior behavior = new AjaxEventBehavior("keyup"){
@Override
protected void onEvent(AjaxRequestTarget target) {
System.out.println("Hello world!");
}
};
form.add(behavior);
在检票我可以做它喜欢previous版本:
In previous versions of Wicket I could have done it like:
behavior.setThrottleDelay(Duration.ONE_SECOND);
不过,由于6.1版本的机会已被删除。而网络是充满了previous版本的教程,它们都含有.setThrottleDelay()方法。
But since version 6.1 this opportunity has been erased. And the web is full of previous versions tutorials which all contain .setThrottleDelay() methods.
基本上,我们的目标是要调出时,该人已停止打字形式的行为。目前,它的每一个即刻当钥匙起床,基本上修建垃圾服务器端的时间调出的行为。这就是为什么我想推迟。背景:目前,我正在试图让查询到数据库中,并得到了相类似的表单输入的数据。和所有的时间,当该人是打字。但延迟将需要在目标保持服务器端/ SQL出轰炸范围的。
Basically, the goal is to call out the behavior when the person has stopped typing in the form. Currently it calls out the behaviour every time INSTANTLY when the key gets up which basically spams the server side. That's why I would like to delay. Background: I'm currently trying to make queries into database and get out the data which are similar to the form input. And all that in the time when the person is typing. But the delay would be needed in goal to keep server-side/SQL out of the "bombarding range".
此外,我愿意接受的替代品。
Also I am open to alternatives.
推荐答案
设置风门的设置已被统一在AjaxRequestAttributes的6.0.0版本的所有其他Ajax设置,这是一个重大的版本,并没有直接替代。
Setting the throttle's settings has been unified with all other Ajax settings in AjaxRequestAttributes for version 6.0.0 which is a major version and was not drop-in replacement.
https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax包含了所有的设置表,节流的是提到在它的底部。
https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax contains a table with all the settings, the throttling ones are mentioned at the bottom of it.
要使用它:
AjaxEventBehavior behavior = new AjaxEventBehavior("keyup") {
@Override
protected void onEvent(AjaxRequestTarget target) {
System.out.println("Hello world!");
}
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
super.updateAjaxAttributes(attributes);
attributes.setThrottlingSettings(new ThrottlingSettings(id, Duration.ONE_SECOND, true));
}
};
最后一个构造函数的参数是你所需要的。检查它的javadoc。
The last constructor argument is what you need. Check its javadoc.
这篇关于检票6.1 AjaxEventBehavior - 如何设置延迟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!