/** * Sets the throttle delay for this behavior. Throttled behaviors only execute once within the * given delay even though they are triggered multiple times. * <p> * For example, this is useful when attaching this behavior to the onkeypress event. It is not * desirable to have an ajax call made every time the user types so we throttle that call to a * desirable delay, such as once per second. This gives us a near real time ability to provide * feedback without overloading the server with ajax calls. * * * @param throttleDelay * throttle delay * @return this for chaining */ public final AjaxEventBehavior setThrottleDelay(Duration throttleDelay) { throttlingSettings = new ThrottlingSettings("th" + (++sequence), throttleDelay); return this; }
protected CharSequence generateCallbackScript(CharSequence partialCall) { CharSequence script = super.generateCallbackScript(partialCall); final ThrottlingSettings ts = throttlingSettings; if (ts != null) { script = AbstractDefaultAjaxBehavior.throttleScript(script, ts.getId(), ts.getDelay()); } return script; }
/** * Sets the throttle delay for this behavior. Throttled behaviors only execute once within the * given delay even though they are triggered multiple times. * <p> * For example, this is useful when attaching this behavior to the onkeypress event. It is not * desirable to have an ajax call made every time the user types so we throttle that call to a * desirable delay, such as once per second. This gives us a near real time ability to provide * feedback without overloading the server with ajax calls. * * * @param throttleDelay * throttle delay * @return this for chaining */ public final AjaxEventBehavior setThrottleDelay(Duration throttleDelay) { throttlingSettings = new ThrottlingSettings("th" + (++sequence), throttleDelay); return this; }
@Override protected CharSequence generateCallbackScript(CharSequence partialCall) { CharSequence script = super.generateCallbackScript(partialCall); final ThrottlingSettings ts = throttlingSettings; if (ts != null) { script = AbstractDefaultAjaxBehavior.throttleScript(script, ts.getId(), ts.getDelay()); } return script; }