01: /*
02: * $Id: org.eclipse.jdt.ui.prefs 5004 2006-03-17 20:47:08 -0800 (Fri, 17 Mar
03: * 2006) eelco12 $ $Revision: 5004 $ $Date: 2006-03-17 20:47:08 -0800 (Fri, 17
04: * Mar 2006) $
05: *
06: * ==============================================================================
07: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
08: * use this file except in compliance with the License. You may obtain a copy of
09: * the License at
10: *
11: * http://www.apache.org/licenses/LICENSE-2.0
12: *
13: * Unless required by applicable law or agreed to in writing, software
14: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16: * License for the specific language governing permissions and limitations under
17: * the License.
18: */
19: package wicket.ajax.calldecorator;
20:
21: import wicket.ajax.IAjaxCallDecorator;
22: import wicket.ajax.markup.html.AjaxFallbackLink;
23:
24: /**
25: * Decorator that can be used to cancel the regular action if ajax call was
26: * performed. This allows us to, for example, cancel the default anchor behavior
27: * (requesting href url) if an ajax call was made in the onclick event handler.
28: * Ajax call cannot be performed if javascript has been turned off or no
29: * compatible XmlHttpRequest object can be found. This decorator will make
30: * javascript return true if the ajax call was made, and false otherwise.
31: *
32: * @see AjaxFallbackLink
33: *
34: * @since 1.2
35: *
36: * @author Igor Vaynberg (ivaynberg)
37: *
38: */
39: public final class CancelEventIfNoAjaxDecorator extends
40: AjaxPostprocessingCallDecorator {
41: private static final long serialVersionUID = 1L;
42:
43: /**
44: * Construct.
45: */
46: public CancelEventIfNoAjaxDecorator() {
47: this ((IAjaxCallDecorator) null);
48: }
49:
50: /**
51: * Constructors that allows chaining of another decorator
52: *
53: * @param delegate
54: */
55: public CancelEventIfNoAjaxDecorator(IAjaxCallDecorator delegate) {
56: super (delegate);
57: }
58:
59: /**
60: * @see wicket.ajax.calldecorator.AjaxPostprocessingCallDecorator#postDecorateScript(CharSequence)
61: */
62: public final CharSequence postDecorateScript(CharSequence script) {
63: return script + "return !"
64: + IAjaxCallDecorator.WICKET_CALL_RESULT_VAR + ";";
65: }
66: }
|