Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.4.5
-
wicket 1.4.5, wicket quickstart, windows XP; FireFox 3.5.7 used in quickstart test
Description
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()
to:
return new AppendingStringBuffer("wicketThrottler.throttle( '").append(throttleId)
.append("', ")
.append(throttleDelay.getMilliseconds())
.append(", function() { ") .append(script) .append("}
.bind(this));");