001: /*
002: * $Id: org.eclipse.jdt.ui.prefs 5004 2006-03-17 20:47:08 -0800 (Fri, 17 Mar
003: * 2006) eelco12 $ $Revision: 5004 $ $Date: 2006-03-17 20:47:08 -0800 (Fri, 17
004: * Mar 2006) $
005: *
006: * ==============================================================================
007: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
008: * use this file except in compliance with the License. You may obtain a copy of
009: * the License at
010: *
011: * http://www.apache.org/licenses/LICENSE-2.0
012: *
013: * Unless required by applicable law or agreed to in writing, software
014: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
015: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
016: * License for the specific language governing permissions and limitations under
017: * the License.
018: */
019: package wicket.ajax.calldecorator;
020:
021: import wicket.ajax.IAjaxCallDecorator;
022:
023: /**
024: * Ajax call decorator that decorates script before passing it to the delegate
025: * decorator
026: *
027: * @see IAjaxCallDecorator for notes on escaping quotes in scripts
028: *
029: * @since 1.2
030: *
031: * @author Igor Vaynberg (ivaynberg)
032: */
033: public class AjaxPreprocessingCallDecorator implements
034: IAjaxCallDecorator {
035: private static final long serialVersionUID = 1L;
036:
037: private final IAjaxCallDecorator delegate;
038:
039: /**
040: * Construct.
041: *
042: * @param delegate
043: */
044: public AjaxPreprocessingCallDecorator(IAjaxCallDecorator delegate) {
045: this .delegate = delegate;
046: }
047:
048: /**
049: * @see wicket.ajax.IAjaxCallDecorator#decorateScript(CharSequence)
050: */
051: public CharSequence decorateScript(CharSequence script) {
052: CharSequence s = (delegate == null) ? script : delegate
053: .decorateScript(script);
054: return preDecorateScript(s);
055: }
056:
057: /**
058: * @see wicket.ajax.IAjaxCallDecorator#decorateOnSuccessScript(java.lang.String)
059: */
060: public CharSequence decorateOnSuccessScript(CharSequence script) {
061: CharSequence s = (delegate == null) ? script : delegate
062: .decorateOnSuccessScript(script);
063: return preDecorateOnSuccessScript(s);
064: }
065:
066: /**
067: * @see wicket.ajax.IAjaxCallDecorator#decorateOnFailureScript(java.lang.String)
068: */
069: public CharSequence decorateOnFailureScript(CharSequence script) {
070: CharSequence s = (delegate == null) ? script : delegate
071: .decorateOnFailureScript(script);
072: return preDecorateOnFailureScript(s);
073: }
074:
075: /**
076: * Decorates ajax call script
077: *
078: * @param script
079: * @return decorated script
080: */
081: public CharSequence preDecorateScript(CharSequence script) {
082: return script;
083: }
084:
085: /**
086: * Decorates success handling script
087: *
088: * @param script
089: * @return decorated script
090: */
091: public CharSequence preDecorateOnSuccessScript(CharSequence script) {
092: return script;
093: }
094:
095: /**
096: * Decorates the failure handling script
097: *
098: * @param script
099: * @return decorated script
100: */
101: public CharSequence preDecorateOnFailureScript(CharSequence script) {
102: return script;
103: }
104:
105: }
|