click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r1027856 - in /click/trunk/click/framework/src/org/apache/click: ActionEventDispatcher.java Behavior.java ClickServlet.java ajax/AjaxBehavior.java ajax/DefaultAjaxBehavior.java ajax/package.html control/AbstractControl.java
Date Wed, 27 Oct 2010 08:50:00 GMT
Author: sabob
Date: Wed Oct 27 08:49:59 2010
New Revision: 1027856

URL: http://svn.apache.org/viewvc?rev=1027856&view=rev
Log:
Moved Ajax functionality into AjaxBehavior

Added:
    click/trunk/click/framework/src/org/apache/click/ajax/DefaultAjaxBehavior.java
      - copied, changed from r978886, click/trunk/click/framework/src/org/apache/click/ajax/AjaxBehavior.java
    click/trunk/click/framework/src/org/apache/click/ajax/package.html   (with props)
Modified:
    click/trunk/click/framework/src/org/apache/click/ActionEventDispatcher.java
    click/trunk/click/framework/src/org/apache/click/Behavior.java
    click/trunk/click/framework/src/org/apache/click/ClickServlet.java
    click/trunk/click/framework/src/org/apache/click/ajax/AjaxBehavior.java
    click/trunk/click/framework/src/org/apache/click/control/AbstractControl.java

Modified: click/trunk/click/framework/src/org/apache/click/ActionEventDispatcher.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/ActionEventDispatcher.java?rev=1027856&r1=1027855&r2=1027856&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/ActionEventDispatcher.java (original)
+++ click/trunk/click/framework/src/org/apache/click/ActionEventDispatcher.java Wed Oct 27
08:49:59 2010
@@ -24,6 +24,7 @@ import java.util.LinkedHashSet;
 
 import java.util.List;
 import java.util.Set;
+import org.apache.click.ajax.AjaxBehavior;
 import org.apache.click.service.ConfigService;
 import org.apache.click.service.LogService;
 import org.apache.click.util.HtmlStringBuffer;
@@ -31,8 +32,8 @@ import org.apache.commons.lang.ClassUtil
 import org.apache.commons.lang.Validate;
 
 /**
- * Provides a control ActionListener and Behavior dispatcher. The
- * ClickServlet will dispatch registered ActionListeners and Behaviors after
+ * Provides a control ActionListener and AjaxBehavior dispatcher. The
+ * ClickServlet will dispatch registered ActionListeners and AjaxBehaviors after
  * page controls have been processed.
  *
  * <h4>Example Usage</h4>
@@ -79,8 +80,8 @@ public class ActionEventDispatcher {
     /** The list of registered event listeners. */
     List<ActionListener> eventListenerList;
 
-    /** The set of Controls with attached Behaviors. */
-    Set<Control> behaviorSourceSet;
+    /** The set of Controls with attached AjaxBehaviors. */
+    Set<Control> ajaxBehaviorSourceSet;
 
     /**
      * The {@link org.apache.click.ActionResult} to render. This action result is
@@ -115,16 +116,16 @@ public class ActionEventDispatcher {
     }
 
     /**
-     * Register the source control which behaviors should be fired by the
+     * Register the source control which AjaxBehaviors should be fired by the
      * ClickServlet.
      *
      * @param source the source control which behaviors should be fired
      */
-    public static void dispatchBehaviors(Control source) {
+    public static void dispatchAjaxBehaviors(Control source) {
         Validate.notNull(source, "Null source parameter");
 
         ActionEventDispatcher instance = getThreadLocalDispatcher();
-        instance.registerBehaviorSource(source);
+        instance.registerAjaxBehaviorSource(source);
     }
 
     /**
@@ -145,22 +146,22 @@ public class ActionEventDispatcher {
     }
 
     /**
-     * Fire all the registered behaviors after the Page Controls have been
-     * processed and return true if the page should continue processing.
+     * Fire all the registered AjaxBehaviors and return true if the page should
+     * continue processing, false otherwise.
      *
-     * @see #fireBehaviors(org.apache.click.Context, java.util.Set)
+     * @see #fireAjaxBehaviors(org.apache.click.Context, java.util.Set)
      *
      * @param context the request context
      *
      * @return true if the page should continue processing, false otherwise
      */
-    public boolean fireBehaviors(Context context) {
+    public boolean fireAjaxBehaviors(Context context) {
 
-        if (!hasBehaviorSourceSet()) {
+        if (!hasAjaxBehaviorSourceSet()) {
             return true;
         }
 
-        return fireBehaviors(context, getBehaviorSourceSet());
+        return fireAjaxBehaviors(context, getAjaxBehaviorSourceSet());
     }
 
     // Protected Methods ------------------------------------------------------
@@ -235,30 +236,30 @@ public class ActionEventDispatcher {
     }
 
     /**
-     * Fire the behaviors for the given control set and return true if the page
+     * Fire the AjaxBehaviors for the given control set and return true if the page
      * should continue processing, false otherwise.
      * <p/>
-     * This method can be overridden if you need to customize the way behaviors
-     * are fired.
+     * This method can be overridden if you need to customize the way
+     * AjaxBehaviors are fired.
      *
-     * @see #fireBehavior(org.apache.click.Context, org.apache.click.Control)
+     * @see #fireAjaxBehaviors(org.apache.click.Context, org.apache.click.Control)
      *
      * @param context the request context
-     * @param behaviorSourceSet the set of controls with attached behaviors
+     * @param ajaxBbehaviorSourceSet the set of controls with attached AjaxBehaviors
      *
      * @return true if the page should continue processing, false otherwise
      */
-    protected boolean fireBehaviors(Context context, Set<Control> behaviorSourceSet)
{
+    protected boolean fireAjaxBehaviors(Context context, Set<Control> ajaxBbehaviorSourceSet)
{
 
         boolean continueProcessing = true;
 
-        for (Iterator<Control> it = behaviorSourceSet.iterator(); it.hasNext();) {
+        for (Iterator<Control> it = ajaxBbehaviorSourceSet.iterator(); it.hasNext();)
{
             Control source = it.next();
 
             // Pop the first entry in the set
             it.remove();
 
-            if (!fireBehavior(context, source)) {
+            if (!fireAjaxBehaviors(context, source)) {
                 continueProcessing = false;
             }
         }
@@ -267,18 +268,20 @@ public class ActionEventDispatcher {
     }
 
     /**
-     * Fire the behavior for the given control and return true if the page
-     * should continue processing, false otherwise.
+     * Fire the AjaxBehaviors for the given control and return true if the
+     * page should continue processing, false otherwise. AjaxBehaviors will
+     * only fire if their {@link org.apache.click.ajax.AjaxBehavior#isAjaxTarget(org.apache.click.Context)
isAjaxTarget()}
+     * method returns true.
      * <p/>
-     * This method can be overridden if you need to customize the way behaviors
-     * are fired.
+     * This method can be overridden if you need to customize the way
+     * AjaxBehaviors are fired.
      *
      * @param context the request context
      * @param source the control which attached behaviors should be fired
      *
      * @return true if the page should continue processing, false otherwise
      */
-    protected boolean fireBehavior(Context context, Control source) {
+    protected boolean fireAjaxBehaviors(Context context, Control source) {
 
         boolean continueProcessing = true;
 
@@ -293,71 +296,85 @@ public class ActionEventDispatcher {
 
         for (Behavior behavior : source.getBehaviors()) {
 
-            boolean isRequestTarget = behavior.isRequestTarget(context);
-
-            if (logger.isTraceEnabled()) {
-                String behaviorClassName = ClassUtils.getShortClassName(behavior.getClass());
-                HtmlStringBuffer buffer = new HtmlStringBuffer();
-                buffer.append("      invoked: ");
-                buffer.append(behaviorClassName);
-                buffer.append(".isRequestTarget() : ");
-                buffer.append(isRequestTarget);
-                logger.trace(buffer.toString());
-            }
+            if (behavior instanceof AjaxBehavior) {
+                AjaxBehavior ajaxBehavior = (AjaxBehavior) behavior;
 
-            if (isRequestTarget) {
+                boolean isAjaxTarget = ajaxBehavior.isAjaxTarget(context);
 
-                // The first non-null ActionResult returned will be rendered, other
-                // ActionResult instances are ignored
-                ActionResult behaviorActionResult = behavior.onAction(source);
-                if (actionResult == null && behaviorActionResult != null) {
-                    actionResult = behaviorActionResult;
+                if (logger.isTraceEnabled()) {
+                    String behaviorClassName = ClassUtils.getShortClassName(
+                        ajaxBehavior.getClass());
+                    HtmlStringBuffer buffer = new HtmlStringBuffer();
+                    buffer.append("      invoked: ");
+                    buffer.append(behaviorClassName);
+                    buffer.append(".isAjaxTarget() : ");
+                    buffer.append(isAjaxTarget);
+                    logger.trace(buffer.toString());
                 }
 
-                if (logger.isTraceEnabled()) {
-                    String behaviorClassName = ClassUtils.getShortClassName(behavior.getClass());
-                    String actionResultClassName = null;
+                if (isAjaxTarget) {
 
-                    if (behaviorActionResult != null) {
-                        actionResultClassName = ClassUtils.getShortClassName(behaviorActionResult.getClass());
+                    // The first non-null ActionResult returned will be rendered, other
+                    // ActionResult instances are ignored
+                    ActionResult behaviorActionResult =
+                        ajaxBehavior.onAction(source);
+                    if (actionResult == null && behaviorActionResult != null) {
+                        actionResult = behaviorActionResult;
                     }
 
-                    HtmlStringBuffer buffer = new HtmlStringBuffer();
-                    buffer.append("      invoked: ");
-                    buffer.append(behaviorClassName);
-                    buffer.append(".onAction() : ");
-                    buffer.append(actionResultClassName);
+                    if (logger.isTraceEnabled()) {
+                        String behaviorClassName = ClassUtils.getShortClassName(
+                            ajaxBehavior.getClass());
+                        String actionResultClassName = null;
+
+                        if (behaviorActionResult != null) {
+                            actionResultClassName = ClassUtils.getShortClassName(
+                                behaviorActionResult.getClass());
+                        }
 
-                    if (actionResult == behaviorActionResult && behaviorActionResult
!= null) {
-                        buffer.append(" (ActionResult will be rendered)");
-                    } else {
-                        if (behaviorActionResult == null) {
-                            buffer.append(" (ActionResult is null and will be ignored)");
+                        HtmlStringBuffer buffer = new HtmlStringBuffer();
+                        buffer.append("      invoked: ");
+                        buffer.append(behaviorClassName);
+                        buffer.append(".onAction() : ");
+                        buffer.append(actionResultClassName);
+
+                        if (actionResult == behaviorActionResult
+                            && behaviorActionResult != null) {
+                            buffer.append(" (ActionResult will be rendered)");
                         } else {
-                            buffer.append(" (ActionResult will be ignored since another Behavior
already retuned a non-null ActionResult)");
+                            if (behaviorActionResult == null) {
+                                buffer.append(" (ActionResult is null and will be ignored)");
+                            } else {
+                                buffer.append(" (ActionResult will be ignored since another
AjaxBehavior already retuned a non-null ActionResult)");
+                            }
                         }
+
+                        logger.trace(buffer.toString());
                     }
 
-                    logger.trace(buffer.toString());
+                    continueProcessing = false;
+                    break;
                 }
-
-                continueProcessing = false;
-                break;
             }
         }
 
         if (logger.isTraceEnabled()) {
 
-            // Provide trace if no target behavior was found
-            if (continueProcessing) {
+            //if (hasAjaxBehavior) {
+
+                // continueProcessing is true if no AjaxBehavior was the target
+                // of the request
+              if (continueProcessing) {
                 HtmlStringBuffer buffer = new HtmlStringBuffer();
-                String sourceClassName = ClassUtils.getShortClassName(source.getClass());
-                buffer.append("   *no* target behavior found for '");
+                String sourceClassName = ClassUtils.getShortClassName(
+                    source.getClass());
+                buffer.append("   *no* target AjaxBehavior found for '");
                 buffer.append(source.getName()).append("' ");
                 buffer.append(sourceClassName);
-                buffer.append(" - invoking Behavior.isRequestTarget() returned false for
all behaviors");
+                buffer.append(" - invoking AjaxBehavior.isAjaxTarget() returned false for
all ajax behaviors");
                 logger.trace(buffer.toString());
             }
+             //}
         }
 
         // Ajax requests stops further processing
@@ -381,14 +398,14 @@ public class ActionEventDispatcher {
     }
 
     /**
-     * Register the behavior source control.
+     * Register the AjaxBehavior source control.
      *
-     * @param source the behavior source control
+     * @param source the AjaxBehavior source control
      */
-    void registerBehaviorSource(Control source) {
+    void registerAjaxBehaviorSource(Control source) {
         Validate.notNull(source, "Null source parameter");
 
-        getBehaviorSourceSet().add(source);
+        getAjaxBehaviorSourceSet().add(source);
     }
 
     /**
@@ -436,8 +453,8 @@ public class ActionEventDispatcher {
             getEventListenerList().clear();
         }
 
-        if (hasBehaviorSourceSet()) {
-            getBehaviorSourceSet().clear();
+        if (hasAjaxBehaviorSourceSet()) {
+            getAjaxBehaviorSourceSet().clear();
         }
     }
 
@@ -451,27 +468,27 @@ public class ActionEventDispatcher {
     }
 
     /**
-     * Return true if a control with behaviors was registered, false otherwise.
+     * Return true if a control with AjaxBehaviors was registered, false otherwise.
      *
-     * @return true if a control with behaviors was registered, false otherwise.
+     * @return true if a control with AjaxBehaviors was registered, false otherwise.
      */
-    boolean hasBehaviorSourceSet() {
-        if (behaviorSourceSet == null || behaviorSourceSet.isEmpty()) {
+    boolean hasAjaxBehaviorSourceSet() {
+        if (ajaxBehaviorSourceSet == null || ajaxBehaviorSourceSet.isEmpty()) {
             return false;
         }
         return true;
     }
 
     /**
-     * Return the set of controls with attached behaviors.
+     * Return the set of controls with attached AjaxBehaviors.
      *
-     * @return set of control with attached behaviors
+     * @return set of control with attached AjaxBehaviors
      */
-    Set<Control> getBehaviorSourceSet() {
-        if (behaviorSourceSet == null) {
-            behaviorSourceSet = new LinkedHashSet<Control>();
+    Set<Control> getAjaxBehaviorSourceSet() {
+        if (ajaxBehaviorSourceSet == null) {
+            ajaxBehaviorSourceSet = new LinkedHashSet<Control>();
         }
-        return behaviorSourceSet;
+        return ajaxBehaviorSourceSet;
     }
 
     /**

Modified: click/trunk/click/framework/src/org/apache/click/Behavior.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/Behavior.java?rev=1027856&r1=1027855&r2=1027856&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/Behavior.java (original)
+++ click/trunk/click/framework/src/org/apache/click/Behavior.java Wed Oct 27 08:49:59 2010
@@ -20,18 +20,10 @@ package org.apache.click;
 
 /**
  * Behaviors provide a mechanism for changing how Controls behave at runtime.
- * Behaviors are added to a Control and uses interceptor methods to decorate and
- * enhance the source Control. Behaviors are most often used to add Ajax support
- * to Controls.
+ * Behaviors are added to a Control and provides interceptor methods to decorate
+ * and enhance the source Control.
  * <p/>
- * To handle an Ajax request Behavior exposes the listener method: {@link #onAction(org.apache.click.Control)
onAction}.
- * The <tt>onAction</tt> method returns an ActionResult that is rendered back
- * to the browser. Before Click invokes the <tt>onAction</tt> method it checks
- * whether the request is targeted at that Behavior by calling the method
- * {@link #isRequestTarget(org.apache.click.Context) Behavior.isRequestTarget()}.
- * Click will only invoke <tt>onAction</tt> if <tt>isRequestTarget</tt>
returns true.
- * <p/>
- * Behaviors also provide interceptor methods for specific Control life cycle events.
+ * Behaviors provide interceptor methods for specific Control life cycle events.
  * These interceptor methods can be implemented to further process and decorate
  * the control or its children.
  * <p/>
@@ -57,60 +49,6 @@ package org.apache.click;
 public interface Behavior {
 
     /**
-     * The behavior action method.
-     *
-     * TODO: javadoc
-     *
-     * @param source the control the behavior is attached to
-     * @return the action result instance
-     */
-    public ActionResult onAction(Control source);
-
-    /**
-     * Return true if the behavior is the request target, false otherwise.
-     * <p/>
-     * This method is queried by Click to determine if the behavior's
-     * {@link #onAction(org.apache.click.Control)} method should be called in
-     * response to a request.
-     * <p/>
-     * By exposing this method through the Behavior interface it provides
-     * implementers with fine grained control over whether the Behavior's
-     * {@link #onAction(org.apache.click.Control)} method should be invoked or not.
-     * <p/>
-     * Below is an example implementation:
-     *
-     * <pre class="prettyprint">
-     * public CustomBehavior implements Behavior {
-     *
-     *     private String eventType;
-     *
-     *     public CustomBehavior(String eventType) {
-     *         // The event type of the behavior
-     *         super(eventType);
-     *     }
-     *
-     *     public boolean isRequestTarget(Context context) {
-     *         // Retrieve the eventType parameter from the incoming request
-     *         String eventType = context.getRequestParameter("type");
-     *
-     *         // Check if this Behavior's eventType matches the request
-     *         // "type" parameter
-     *         return StringUtils.equalsIgnoreCase(this.eventType, eventType);
-     *     }
-     *
-     *     public ActionResult onAction(Control source) {
-     *         // If isRequestTarget returned true, the onAction method will be
-     *         // invoked
-     *         ...
-     *     }
-     * } </pre>
-     *
-     * @param context the request context
-     * @return true if the behavior is the request target, false otherwise
-     */
-    public boolean isRequestTarget(Context context);
-
-    /**
      * This event occurs before the markup is written to the HttpServletResponse.
      *
      * @param source the control the behavior is registered with

Modified: click/trunk/click/framework/src/org/apache/click/ClickServlet.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/ClickServlet.java?rev=1027856&r1=1027855&r2=1027856&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/ClickServlet.java (original)
+++ click/trunk/click/framework/src/org/apache/click/ClickServlet.java Wed Oct 27 08:49:59
2010
@@ -1832,10 +1832,10 @@ public class ClickServlet extends HttpSe
                 // Perform onProcess for regsitered Ajax controls
                 processAjaxTargetControls(context, eventDispatcher, controlRegistry);
 
-                // Fire behaviors registered during the onProcess event
-                // The target behavior will set the eventDispatcher action result instance
-                // to render
-                eventDispatcher.fireBehaviors(context);
+                // Fire AjaxBehaviors registered during the onProcess event
+                // The target AjaxBehavior will set the eventDispatcher action
+                // result instance to render
+                eventDispatcher.fireAjaxBehaviors(context);
 
                 // Ensure we execute the beforeResponse and beforeGetHeadElements
                 // for Ajax requests
@@ -1850,7 +1850,7 @@ public class ClickServlet extends HttpSe
             } else {
 
                 // If no target Ajax controls have been registered fallback to
-                // the old behavior or processing and rendering the page template
+                // the old behavior of processing and rendering the page template
                if (logger.isTraceEnabled()) {
                     String msg = "   *no* Ajax target controls have been registered."
                         + " Will process the page as a normal non Ajax request.";
@@ -1920,8 +1920,8 @@ public class ClickServlet extends HttpSe
                 buffer.append(".onProcess() : ").append(continueProcessing);
                 logger.trace(buffer.toString());
 
-                if (!eventDispatcher.hasBehaviorSourceSet()) {
-                    logger.trace("   *no* behavior was registered while processing the control");
+                if (!eventDispatcher.hasAjaxBehaviorSourceSet()) {
+                    logger.trace("   *no* AjaxBehavior was registered while processing the
control");
                 }
             }
         }

Modified: click/trunk/click/framework/src/org/apache/click/ajax/AjaxBehavior.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/ajax/AjaxBehavior.java?rev=1027856&r1=1027855&r2=1027856&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/ajax/AjaxBehavior.java (original)
+++ click/trunk/click/framework/src/org/apache/click/ajax/AjaxBehavior.java Wed Oct 27 08:49:59
2010
@@ -18,78 +18,77 @@
  */
 package org.apache.click.ajax;
 
-import java.io.Serializable;
+import org.apache.click.ActionResult;
 import org.apache.click.Behavior;
 import org.apache.click.Context;
 import org.apache.click.Control;
-import org.apache.click.ActionResult;
 
 /**
- * Provides an abstract implementation of the Behavior interface.
- *
- * TODO: javadoc
+ * AjaxBehavior extends the basic Behavior functionality to allow Controls to
+ * handle and process incoming Ajax requests.
+ * <p/>
+ * To handle an Ajax request, AjaxBehavior exposes the listener method:
+ * {@link #onAction(org.apache.click.Control) onAction}.
+ * The <tt>onAction</tt> method returns an ActionResult that is rendered back
+ * to the browser.
+ * <p/>
+ * Before Click invokes the <tt>onAction</tt> method it checks whether the request
+ * is targeted at the AjaxBehavior by invoking the method
+ * {@link #isAjaxTarget(org.apache.click.Context) Behavior.isAjaxTarget()}.
+ * Click will only invoke <tt>onAction</tt> if <tt>isAjaxTarget</tt>
returns true.
  */
-public class AjaxBehavior implements Behavior, Serializable {
-
-    // Constants --------------------------------------------------------------
-
-    private static final long serialVersionUID = 1L;
-
-    // Variables --------------------------------------------------------------
-
-    protected boolean headElementsProcessed = false;
-
-    // Behavior Methods--------------------------------------------------------
+public interface AjaxBehavior extends Behavior {
 
     /**
-     * @see org.apache.click.Behavior#onAction(org.apache.click.Control)
      *
-     * @param source the control the behavior is attached to
-     * @return the action result
-     */
-    public ActionResult onAction(Control source) {
-        return null;
-    }
-
-    /**
      * TODO: javadoc
      *
-     * @param context
-     * @return
+     * @param source the control the behavior is attached to
+     * @return the action result instance
      */
-    public boolean isRequestTarget(Context context) {
-        return true;
-    }
-
-    // Callback Methods -------------------------------------------------------
+    public ActionResult onAction(Control source);
 
     /**
+     * Return true if the behavior is the request target, false otherwise.
+     * <p/>
+     * This method is queried by Click to determine if the behavior's
+     * {@link #onAction(org.apache.click.Control)} method should be called in
+     * response to a request.
+     * <p/>
+     * By exposing this method through the Behavior interface it provides
+     * implementers with fine grained control over whether the Behavior's
+     * {@link #onAction(org.apache.click.Control)} method should be invoked or not.
+     * <p/>
+     * Below is an example implementation:
      *
-     * @param source
+     * <pre class="prettyprint">
+     * public CustomBehavior implements Behavior {
+     *
+     *     private String eventType;
+     *
+     *     public CustomBehavior(String eventType) {
+     *         // The event type of the behavior
+     *         super(eventType);
+     *     }
+     *
+     *     public boolean isAjaxTarget(Context context) {
+     *         // Retrieve the eventType parameter from the incoming request
+     *         String eventType = context.getRequestParameter("type");
+     *
+     *         // Check if this Behavior's eventType matches the request
+     *         // "type" parameter
+     *         return StringUtils.equalsIgnoreCase(this.eventType, eventType);
+     *     }
+     *
+     *     public ActionResult onAction(Control source) {
+     *         // If isAjaxTarget returned true, the onAction method will be
+     *         // invoked
+     *         ...
+     *     }
+     * } </pre>
+     *
+     * @param context the request context
+     * @return true if the behavior is the request target, false otherwise
      */
-    public void preResponse(Control source) {
-    }
-
-    public void preGetHeadElements(Control source) {
-        // Guard against adding HEAD elements to more than one control
-        if (headElementsProcessed) {
-            return;
-        }
-
-        addHeadElements(source);
-
-        headElementsProcessed = true;
-    }
-
-    public void preDestroy(Control source) {
-        headElementsProcessed = false;
-    }
-
-    // Protected methods ------------------------------------------------------
-
-    protected void addHeadElements(Control source) {
-        // Subclasses can override the default to add head specific elements
-        // NOTE: if this method is ever made public the headElementsProcessed
-        // check should be done here
-    }
+    public boolean isAjaxTarget(Context context);
 }

Copied: click/trunk/click/framework/src/org/apache/click/ajax/DefaultAjaxBehavior.java (from
r978886, click/trunk/click/framework/src/org/apache/click/ajax/AjaxBehavior.java)
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/ajax/DefaultAjaxBehavior.java?p2=click/trunk/click/framework/src/org/apache/click/ajax/DefaultAjaxBehavior.java&p1=click/trunk/click/framework/src/org/apache/click/ajax/AjaxBehavior.java&r1=978886&r2=1027856&rev=1027856&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/ajax/AjaxBehavior.java (original)
+++ click/trunk/click/framework/src/org/apache/click/ajax/DefaultAjaxBehavior.java Wed Oct
27 08:49:59 2010
@@ -18,22 +18,17 @@
  */
 package org.apache.click.ajax;
 
-import java.io.Serializable;
 import org.apache.click.Behavior;
 import org.apache.click.Context;
 import org.apache.click.Control;
 import org.apache.click.ActionResult;
 
 /**
- * Provides an abstract implementation of the Behavior interface.
+ * Provides a default implementation of the AjaxBehavior interface.
  *
  * TODO: javadoc
  */
-public class AjaxBehavior implements Behavior, Serializable {
-
-    // Constants --------------------------------------------------------------
-
-    private static final long serialVersionUID = 1L;
+public class DefaultAjaxBehavior implements AjaxBehavior {
 
     // Variables --------------------------------------------------------------
 
@@ -57,7 +52,7 @@ public class AjaxBehavior implements Beh
      * @param context
      * @return
      */
-    public boolean isRequestTarget(Context context) {
+    public boolean isAjaxTarget(Context context) {
         return true;
     }
 

Added: click/trunk/click/framework/src/org/apache/click/ajax/package.html
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/ajax/package.html?rev=1027856&view=auto
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/ajax/package.html (added)
+++ click/trunk/click/framework/src/org/apache/click/ajax/package.html Wed Oct 27 08:49:59
2010
@@ -0,0 +1,29 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.
+-->
+
+<body>
+Provides Ajax support for controls, allowing them to handle and respond to Ajax
+requests. This is achieved through the {@link org.apache.click.ajax.AjaxBehavior}
+interface which extends {@link org.apache.click.Behavior} and adds the
+{@link org.apache.click.ajax.AjaxBehavior#onAction(org.apache.click.Control)}
+method for handling Ajax requests.
+<p/>
+A default AjaxBehavior implementation is provided by the
+{@link org.apache.click.ajax.DefaultAjaxBehavior} class.
+</body>
\ No newline at end of file

Propchange: click/trunk/click/framework/src/org/apache/click/ajax/package.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Modified: click/trunk/click/framework/src/org/apache/click/control/AbstractControl.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/control/AbstractControl.java?rev=1027856&r1=1027855&r2=1027856&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/control/AbstractControl.java (original)
+++ click/trunk/click/framework/src/org/apache/click/control/AbstractControl.java Wed Oct
27 08:49:59 2010
@@ -907,7 +907,7 @@ public abstract class AbstractControl im
      * Dispatch an action event to the {@link org.apache.click.ActionEventDispatcher}.
      *
      * @see org.apache.click.ActionEventDispatcher#dispatchActionEvent(org.apache.click.Control,
org.apache.click.ActionListener)
-     * @see org.apache.click.ActionEventDispatcher#dispatchBehavior(org.apache.click.Control)
+     * @see org.apache.click.ActionEventDispatcher#dispatchAjaxBehaviors(org.apache.click.Control)
      */
     protected void dispatchActionEvent() {
         if (getActionListener() != null) {
@@ -915,7 +915,7 @@ public abstract class AbstractControl im
         }
 
         if (hasBehaviors()) {
-            ActionEventDispatcher.dispatchBehaviors(this);
+            ActionEventDispatcher.dispatchAjaxBehaviors(this);
         }
     }
 



Mime
View raw message