Throttling breaks AjaxFormSubmitBehavior's precondition check -------------------------------------------------------------
Key: WICKET-2739 URL: https://issues.apache.org/jira/browse/WICKET-2739 Project: Wicket Issue Type: Bug Components: wicket Affects Versions: 1.4.5 Environment: wicket 1.4.5, wicket quickstart, windows XP; FireFox 3.5.7 used in quickstart test Reporter: Russell Morrisey AjaxFormSubmitBehavior#getPreconditionScript() looks like: return "return Wicket.$$(this)&&Wicket.$$('" + getForm().getMarkupId() + "')"; The javascript keyword 'this' should point to the DOM element which initiated the ajax event. (It wants to check that the component still exists on the page, before initiating the ajax request, as well as the form this behavior is linked to). When using an AjaxThrottlingCallDecorator to throttle the ajax request, the throttle callback function is not bound to the DOM element. The result is that 'this' refers to the window element, in the context of the throttle callback. The precondition function gets bind(this) called on it, but it's the wrong 'this'. I think that the throttle callback should be bound to 'this' at the time the callback is defined. AbstractDefaultAjaxBehavior#throttleScript(...) should be changed from: return new AppendingStringBuffer("wicketThrottler.throttle( '").append(throttleId) .append("', ") .append(throttleDelay.getMilliseconds()) .append(", function() { ") .append(script) .append("});"); to: return new AppendingStringBuffer("wicketThrottler.throttle( '").append(throttleId) .append("', ") .append(throttleDelay.getMilliseconds()) .append(", function() { ") .append(script) .append("}.bind(this));"); -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.