01: /*
02: * $Id: org.eclipse.jdt.ui.prefs,v 1.6 2006/02/06 08:27:03 ivaynberg Exp $
03: * $Revision: 1.6 $ $Date: 2006/02/06 08:27:03 $
04: *
05: * ==============================================================================
06: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
07: * use this file except in compliance with the License. You may obtain a copy of
08: * the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15: * License for the specific language governing permissions and limitations under
16: * the License.
17: */
18: package wicket.ajax;
19:
20: import java.io.Serializable;
21:
22: /**
23: * Interface used to decorate a wicket generated javascript that performs an
24: * ajax callback
25: * <p>
26: * The returned scripts are rendered in the HTML as follow:
27: *
28: * <pre>
29: * <a href="javascript:[script]var wcall=wicketAjaxGet('[url]', function() {[onSuccessScript]},
30: * function() {[onFailureScript});" ...>[text of the link]</a>
31: * </pre>
32: *
33: * As a result, using double quotes in the script will break the link syntax and
34: * make it fail (or fallback in the case of an AjaxFallbackLink). So, if single
35: * quotes have to be inserted in strings contained in the scripts, they must be
36: * properly escaped to pass through Java and Javascript, for example:
37: *
38: * <pre>
39: * return "alert('It\\'s ok!')";
40: * </pre>
41: *
42: * Also note that <tt>decorateScript(CharSequence script)</tt> should
43: * generally append to the script rather than replace it:
44: *
45: * <pre>
46: * return "alert('Before ajax call');" + script;
47: * </pre>
48: *
49: * Both following examples will break the link:
50: *
51: * <pre>
52: * return "alert('Before ajax call');"; // missing to append the script
53: * return "alert('Before ajax call')" + script; // missing ";"
54: * </pre>
55: *
56: * @since 1.2
57: *
58: * @author Igor Vaynberg (ivaynberg)
59: *
60: */
61: public interface IAjaxCallDecorator extends Serializable {
62: /**
63: * Name of javascript variable that will be true if ajax call was made,
64: * false otherwise. This variable is available in the after script only.
65: */
66: public static final String WICKET_CALL_RESULT_VAR = "wcall";
67:
68: /**
69: * Decorates the script that performs the ajax call
70: *
71: * @param script
72: * @return decorated script
73: */
74: CharSequence decorateScript(CharSequence script);
75:
76: /**
77: * Decorates the onSuccess handler script
78: *
79: * @param script
80: * @return decorated onSuccess handler script
81: */
82: CharSequence decorateOnSuccessScript(CharSequence script);
83:
84: /**
85: * Decorates the onFailure handler script
86: *
87: * @param script
88: * @return decorated onFailure handler script
89: */
90: CharSequence decorateOnFailureScript(CharSequence script);
91:
92: }
|