WICKET-5305 make throttlesettings#id default to component's markup id

Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/badf6681
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/badf6681
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/badf6681

Branch: refs/heads/5299-ajax-strategy
Commit: badf668195cce894ce7658557b231823da9083a8
Parents: db8f694
Author: Carl-Eric Menzel <cmen...@wicketbuch.de>
Authored: Wed Aug 7 14:00:28 2013 +0200
Committer: Carl-Eric Menzel <cmen...@wicketbuch.de>
Committed: Wed Aug 7 14:00:36 2013 +0200

----------------------------------------------------------------------
 .../ajax/AbstractDefaultAjaxBehavior.java       |  8 ++++--
 .../ajax/attributes/ThrottlingSettings.java     | 30 ++++++++++++++++++--
 2 files changed, 34 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/badf6681/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
 
b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
index 8c7acaf..35605f1 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
@@ -356,8 +356,12 @@ public abstract class AbstractDefaultAjaxBehavior extends 
AbstractAjaxBehavior
                        if (throttlingSettings != null)
                        {
                                JSONObject throttlingSettingsJson = new 
JSONObject();
-                               
throttlingSettingsJson.put(AjaxAttributeName.THROTTLING_ID.jsonName(),
-                                       throttlingSettings.getId());
+                               String throttleId = throttlingSettings.getId();
+                               if (throttleId == null)
+                               {
+                                       throttleId = component.getMarkupId();
+                               }
+                               
throttlingSettingsJson.put(AjaxAttributeName.THROTTLING_ID.jsonName(), 
throttleId);
                                
throttlingSettingsJson.put(AjaxAttributeName.THROTTLING_DELAY.jsonName(),
                                        
throttlingSettings.getDelay().getMilliseconds());
                                if 
(throttlingSettings.getPostponeTimerOnUpdate())

http://git-wip-us.apache.org/repos/asf/wicket/blob/badf6681/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/ThrottlingSettings.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/ThrottlingSettings.java
 
b/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/ThrottlingSettings.java
index 079b586..42c6d7d 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/ThrottlingSettings.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/ThrottlingSettings.java
@@ -35,6 +35,31 @@ public class ThrottlingSettings implements IClusterable
        private boolean postponeTimerOnUpdate;
 
        /**
+        * Construct without id (will default to the component's markup ID) and 
postponeTimerOnUpdate
+        * set to false.
+        * 
+        * @param delay
+        *            throttle delay
+        */
+       public ThrottlingSettings(final Duration delay)
+       {
+               this(null, delay, false);
+       }
+
+       /**
+        * Construct without id (will default to the component's markup ID).
+        * 
+        * @param delay
+        *            throttle delay
+        * @param postponeTimerOnUpdate
+        *            postpone timer
+        */
+       public ThrottlingSettings(final Duration delay, boolean 
postponeTimerOnUpdate)
+       {
+               this(null, delay, postponeTimerOnUpdate);
+       }
+
+       /**
         * Construct.
         * 
         * @param id
@@ -58,7 +83,7 @@ public class ThrottlingSettings implements IClusterable
        public ThrottlingSettings(final String id, final Duration delay,
                final boolean postponeTimerOnUpdate)
        {
-               this.id = Args.notNull(id, "id");
+               this.id = id;
                this.delay = Args.notNull(delay, "delay");
                this.postponeTimerOnUpdate = postponeTimerOnUpdate;
        }
@@ -80,7 +105,8 @@ public class ThrottlingSettings implements IClusterable
         * This id is used by the client-side throttling code to keep track of 
the various event
         * throttles. Normally you can just use any unique ID here, such as the 
component's markupId (
         * {@link WebComponent#getMarkupId()}). To unite several different 
events with one throttle,
-        * give them the same ID.
+        * give them the same ID. If this is null, it will (on the client only) 
default to the
+        * component's markupId.
         * 
         * @return throttle id
         */

Reply via email to