|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IAjaxCallDecorator
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 ";"
Ajax call decorators are potential contributors to the page header by implementing
IComponentAwareHeaderContributor
. E.g. the decoration
may depend on some JavaScript library, by implementing IComponentAwareHeaderContributor
interface they can assure it will be loaded.
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(Component component,
CharSequence script)
Decorates the onFailure handler script |
CharSequence |
decorateOnSuccessScript(Component component,
CharSequence script)
Decorates the onSuccess handler script |
CharSequence |
decorateScript(Component component,
CharSequence script)
Decorates the script that performs the ajax call |
Field Detail |
---|
static final String WICKET_CALL_RESULT_VAR
Method Detail |
---|
CharSequence decorateScript(Component component, CharSequence script)
component
- script
-
CharSequence decorateOnSuccessScript(Component component, CharSequence script)
component
- script
-
CharSequence decorateOnFailureScript(Component component, CharSequence script)
component
- script
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |