Interface used to decorate a wicket generated javascript that performs an
ajax callback
The returned scripts are rendered in the HTML as follow:
<a href="javascript:[script]var wcall=wicketAjaxGet('[url]', function() {[onSuccessScript]},
function() {[onFailureScript});" ...>[text of the link]</a>
As a result, using double quotes in the script will break the link syntax and
make it fail (or fallback in the case of an AjaxFallbackLink). So, if single
quotes have to be inserted in strings contained in the scripts, they must be
properly escaped to pass through Java and Javascript, for example:
return "alert('It\\'s ok!')";
Also note that decorateScript(CharSequence script) should
generally append to the script rather than replace it:
return "alert('Before ajax call');" + script;
Both following examples will break the link:
return "alert('Before ajax call');"; // missing to append the script
return "alert('Before ajax call')" + script; // missing ";"
since: 1.2 author: Igor Vaynberg (ivaynberg) |