org.apache.wicket.ajax
Interface IAjaxCallDecorator

All Superinterfaces:
IClusterable, Serializable
All Known Implementing Classes:
AjaxCallDecorator, AjaxCallThrottlingDecorator, AjaxPostprocessingCallDecorator, AjaxPreprocessingCallDecorator, CancelEventIfNoAjaxDecorator

public interface IAjaxCallDecorator
extends IClusterable

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)

Field Summary
static String WICKET_CALL_RESULT_VAR
          Name of javascript variable that will be true if ajax call was made, false otherwise.
 
Method Summary
 CharSequence decorateOnFailureScript(CharSequence script)
          Decorates the onFailure handler script
 CharSequence decorateOnSuccessScript(CharSequence script)
          Decorates the onSuccess handler script
 CharSequence decorateScript(CharSequence script)
          Decorates the script that performs the ajax call
 

Field Detail

WICKET_CALL_RESULT_VAR

static final String WICKET_CALL_RESULT_VAR
Name of javascript variable that will be true if ajax call was made, false otherwise. This variable is available in the after script only.

See Also:
Constant Field Values
Method Detail

decorateScript

CharSequence decorateScript(CharSequence script)
Decorates the script that performs the ajax call

Parameters:
script -
Returns:
decorated script

decorateOnSuccessScript

CharSequence decorateOnSuccessScript(CharSequence script)
Decorates the onSuccess handler script

Parameters:
script -
Returns:
decorated onSuccess handler script

decorateOnFailureScript

CharSequence decorateOnFailureScript(CharSequence script)
Decorates the onFailure handler script

Parameters:
script -
Returns:
decorated onFailure handler script


Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.