Author: jcompagner
Date: Thu Jun  7 14:39:55 2007
New Revision: 545324

URL: http://svn.apache.org/viewvc?view=rev&rev=545324
Log:
api cleanup and a refactor of some getCallbackScript methods.
its now much more obvious what to call and what to override when you want 
something. (success or failure scripts)

Modified:
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java?view=diff&rev=545324&r1=545323&r2=545324
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java
 Thu Jun  7 14:39:55 2007
@@ -81,16 +81,22 @@
 
        protected CharSequence getCallbackScript()
        {
+               return generateCallbackScript("wicketAjaxGet('"
+                               + getCallbackUrl(onlyTargetActivePage()) + "'");
+       }
+       
+       /**
+        * @see 
org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#getPreconditonScript()
+        */
+       protected CharSequence getPreconditonScript()
+       {
                String precondition = null;
-               
                if ( !(getComponent() instanceof Page) )
                {
                        String componentId = getComponent().getMarkupId();
                        precondition = "var c = Wicket.$('" + componentId + 
"'); return typeof(c) != 'undefined' && c != null";
                }
-               
-               return getCallbackScript("wicketAjaxGet('"
-                               + getCallbackUrl(onlyTargetActivePage()) + "'", 
null, null, precondition);
+               return precondition;
        }
        
        protected boolean onlyTargetActivePage() {

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java?view=diff&rev=545324&r1=545323&r2=545324
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
 Thu Jun  7 14:39:55 2007
@@ -110,36 +110,36 @@
         */
        protected CharSequence getCallbackScript(boolean onlyTargetActivePage)
        {
-               return getCallbackScript("wicketAjaxGet('"
-                               + getCallbackUrl(onlyTargetActivePage) + "'", 
null, null);
+               return generateCallbackScript("wicketAjaxGet('" + 
getCallbackUrl(onlyTargetActivePage) + "'");
        }
 
        /**
-        * Returns javascript that performs an ajax callback to this behavior. 
The
-        * script is decorated by the ajax callback decorator from
-        * [EMAIL PROTECTED] 
AbstractDefaultAjaxBehavior#getAjaxCallDecorator()}.
-        * 
-        * @param partialCall
-        *            Javascript of a partial call to the function performing 
the
-        *            actual ajax callback. Must be in format
-        *            <code>function(params,</code> with signature
-        *            <code>function(params, onSuccessHandler, 
onFailureHandler</code>.
-        *            Example: <code>wicketAjaxGet('callbackurl'</code>
-        * @param onSuccessScript
-        *            javascript that will run when the ajax call finishes
+        * @return javascript that will run when the ajax call finishes
         *            successfully
-        * @param onFailureScript
-        *            javascript that will run when the ajax call finishes with 
an
+        */
+       protected CharSequence getPreconditonScript()
+       {
+               return null;
+       }
+
+       /**
+        * @return javascript that will run when the ajax call finishes with an
         *            error status
-        * 
-        * @return script that peforms ajax callback to this behavior
         */
-       protected CharSequence getCallbackScript(final CharSequence partialCall,
-                       final CharSequence onSuccessScript, final CharSequence 
onFailureScript)
+       protected CharSequence getFailureScript()
+       {
+               return null;
+       }
+
+       /**
+        * @return an optional javacript expression that determines whether the 
request
+        *            will actually execute (in form of return XXX;);
+        */
+       protected CharSequence getSuccessScript()
        {
-               return getCallbackScript(partialCall, onSuccessScript, 
onFailureScript, null);
+               return null;
        }
-       
+
        /**
         * Returns javascript that performs an ajax callback to this behavior. 
The
         * script is decorated by the ajax callback decorator from
@@ -151,22 +151,15 @@
         *            <code>function(params,</code> with signature
         *            <code>function(params, onSuccessHandler, 
onFailureHandler</code>.
         *            Example: <code>wicketAjaxGet('callbackurl'</code>
-        * @param onSuccessScript
-        *            javascript that will run when the ajax call finishes
-        *            successfully
-        * @param onFailureScript
-        *            javascript that will run when the ajax call finishes with 
an
-        *            error status
-        * @param precondition
-        *                        optional javacript expression that determines 
whether the request
-        *            will actually execute (in form of return XXX;);
         * 
         * @return script that peforms ajax callback to this behavior
         */
-       protected CharSequence getCallbackScript(final CharSequence partialCall,
-                       final CharSequence onSuccessScript, final CharSequence 
onFailureScript, 
-                       final CharSequence precondition)
+       protected CharSequence generateCallbackScript(final CharSequence 
partialCall)
        {
+               final CharSequence onSuccessScript = getSuccessScript();
+               final CharSequence onFailureScript = getFailureScript();
+               final CharSequence precondition = getPreconditonScript();
+
                final IAjaxCallDecorator decorator = getAjaxCallDecorator();
 
                String indicatorId = findIndicatorId();

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java?view=diff&rev=545324&r1=545323&r2=545324
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
 Thu Jun  7 14:39:55 2007
@@ -125,11 +125,9 @@
                return handler;
        }
 
-       protected CharSequence getCallbackScript(CharSequence partialCall,
-                       CharSequence onSuccessScript, CharSequence 
onFailureScript)
+       protected CharSequence generateCallbackScript(CharSequence partialCall)
        {
-               CharSequence script = super
-                               .getCallbackScript(partialCall, 
onSuccessScript, onFailureScript);
+               CharSequence script = super.generateCallbackScript(partialCall);
                final ThrottlingSettings ts = throttlingSettings;
 
                if (ts != null)

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java?view=diff&rev=545324&r1=545323&r2=545324
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java
 Thu Jun  7 14:39:55 2007
@@ -129,10 +129,10 @@
         */
        protected final CharSequence getEventHandler()
        {
-               return getCallbackScript(new 
AppendingStringBuffer("wicketAjaxPost('").append(
+               return generateCallbackScript(new 
AppendingStringBuffer("wicketAjaxPost('").append(
                                getCallbackUrl()).append(
                                "', 
wicketSerializeForm(document.getElementById('" + getComponent().getMarkupId()
-                                               + "',false))"), null, null);
+                                               + "',false))"));
        }
 
        /**

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java?view=diff&rev=545324&r1=545323&r2=545324
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java
 Thu Jun  7 14:39:55 2007
@@ -84,10 +84,10 @@
         */
        protected final CharSequence getEventHandler()
        {
-               return getCallbackScript(new 
AppendingStringBuffer("wicketAjaxPost('").append(
+               return generateCallbackScript(new 
AppendingStringBuffer("wicketAjaxPost('").append(
                                getCallbackUrl(false)).append(
                                "', wicketSerialize(Wicket.$('" + 
getComponent().getMarkupId()
-                                               + "'))"), null, null);
+                                               + "'))"));
        }
 
        /**

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java?view=diff&rev=545324&r1=545323&r2=545324
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
 Thu Jun  7 14:39:55 2007
@@ -20,9 +20,7 @@
 import org.apache.wicket.Page;
 import org.apache.wicket.ajax.AjaxEventBehavior;
 import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.markup.html.form.Button;
 import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.markup.html.form.FormComponent;
 import org.apache.wicket.markup.html.form.IFormSubmittingComponent;
 import org.apache.wicket.util.string.AppendingStringBuffer;
 
@@ -125,7 +123,7 @@
                        call.append("null");
                }
 
-               return getCallbackScript(call, null, null) + ";";
+               return generateCallbackScript(call) + ";";
        }
 
        protected void onEvent(AjaxRequestTarget target)


Reply via email to