Not sure why, but, in 1.5.2 (at least), the call order is such that prependJavascript is not called on AjaxRequestTarget until after constructResponseBody() has passed...
Iterator<CharSequence> it = prependJavaScripts.iterator(); while (it.hasNext()) { CharSequence js = it.next(); respondInvocation(bodyResponse, js); } ...assuring that no prepended scripts are attached to the ajax return. At least from onBeforeRender(). I can freely add any appended script I want, but no prepended ones. This strikes me as not good. Very bad. My code bits... @Override protected void onBeforeRender () { if ((activeRequestHandler = getRequestCycle().getActiveRequestHandler()) instanceof AjaxRequestTarget) { ((AjaxRequestTarget)activeRequestHandler). prependJavaScript ("alert('never called')"); ((AjaxRequestTarget)activeRequestHandler). appendJavaScript ("alert('always called')"); } } David