You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by sa...@apache.org on 2010/11/01 11:19:11 UTC

svn commit: r1029601 - /click/trunk/click/framework/src/org/apache/click/ajax/DefaultAjaxBehavior.java

Author: sabob
Date: Mon Nov  1 10:19:10 2010
New Revision: 1029601

URL: http://svn.apache.org/viewvc?rev=1029601&view=rev
Log:
renamed addHeadElements to addHeadElementsOnce

Modified:
    click/trunk/click/framework/src/org/apache/click/ajax/DefaultAjaxBehavior.java

Modified: click/trunk/click/framework/src/org/apache/click/ajax/DefaultAjaxBehavior.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/ajax/DefaultAjaxBehavior.java?rev=1029601&r1=1029600&r2=1029601&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/ajax/DefaultAjaxBehavior.java (original)
+++ click/trunk/click/framework/src/org/apache/click/ajax/DefaultAjaxBehavior.java Mon Nov  1 10:19:10 2010
@@ -25,21 +25,29 @@ import org.apache.click.ActionResult;
 
 /**
  * Provides a default implementation of the AjaxBehavior interface.
- *
- * TODO: javadoc
+ * <p/>
+ * This class also provides the method,
+ * {@link #addHeadElementsOnce(org.apache.click.Control) addHeadElementsOnce},
+ * that subclasses can implement if they need to add HTML HEAD elements only to
+ * the <tt>first</tt> Control that this Behavior is registered with.
+ * <p/>
+ * If this Behavior should add HTML HEAD elements to all the Controls it is
+ * registered with, rather implement
+ * {@link #preRenderHeadElements(org.apache.click.Control) preRenderHeadElements}.
  */
 public class DefaultAjaxBehavior implements AjaxBehavior {
 
     // Variables --------------------------------------------------------------
 
+    /** Indicates whether the Behavior HEAD elements have been processed or not. */
     protected boolean headElementsProcessed = false;
 
-    // Behavior Methods--------------------------------------------------------
+    // Behavior Methods -------------------------------------------------------
 
     /**
      * @see org.apache.click.Behavior#onAction(org.apache.click.Control)
      *
-     * @param source the control the behavior is attached to
+     * @param source the control the behavior is registered with
      * @return the action result
      */
     public ActionResult onAction(Control source) {
@@ -47,10 +55,10 @@ public class DefaultAjaxBehavior impleme
     }
 
     /**
-     * TODO: javadoc
+     * @see org.apache.click.ajax.AjaxBehavior#isAjaxTarget(org.apache.click.Context)
      *
-     * @param context
-     * @return
+     * @param context the request context
+     * @return true if the behavior is the request target, false otherwise
      */
     public boolean isAjaxTarget(Context context) {
         return true;
@@ -59,19 +67,25 @@ public class DefaultAjaxBehavior impleme
     // Callback Methods -------------------------------------------------------
 
     /**
+     * @see org.apache.click.Behavior#preResponse(org.apache.click.Control)
      *
-     * @param source
+     * @param source the control the behavior is registered with
      */
     public void preResponse(Control source) {
     }
 
+    /**
+     * @see org.apache.click.Behavior#preRenderHeadElements(org.apache.click.Control)
+     *
+     * @param source the control the behavior is registered with
+     */
     public void preRenderHeadElements(Control source) {
         // Guard against adding HEAD elements to more than one control
         if (headElementsProcessed) {
             return;
         }
 
-        addHeadElements(source);
+        addHeadElementsOnce(source);
 
         headElementsProcessed = true;
     }
@@ -82,7 +96,19 @@ public class DefaultAjaxBehavior impleme
 
     // Protected methods ------------------------------------------------------
 
-    protected void addHeadElements(Control source) {
+    /**
+     * Provides a method for adding HTML HEAD elements to the first Control
+     * this Behavior was registered with. This method will only be called once,
+     * passing in the first Control the Behavior was registered with.
+     * <p/>
+     * Subclasses can implement this method instead of
+     * {@link #preRenderHeadElements(org.apache.click.Control)} if HTML HEAD
+     * elements should only be added to one Control, even if the Behavior is
+     * added to multiple Controls.
+     *
+     * @param source the control the behavior is registered with
+     */
+    protected void addHeadElementsOnce(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