You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2012/02/24 08:44:17 UTC

[1/2] git commit: Log a warning if there an Ajax event behavior is overriding the value of the inline attribute for its event. In most cases this means that there are two or more ajax event behaviors on the same event and the last one silently wins.

Updated Branches:
  refs/heads/wicket-1.5.x 229f465b7 -> 19bc50d01


Log a warning if there an Ajax event behavior is overriding the value of the inline attribute for its event. In most cases this means that there are two or more ajax event behaviors on the same event and the last one silently wins.


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

Branch: refs/heads/wicket-1.5.x
Commit: 72b6f6378b33551cad844aeec78ff9d7fe49e0a7
Parents: 229f465
Author: martin-g <mg...@apache.org>
Authored: Fri Feb 24 08:35:29 2012 +0100
Committer: martin-g <mg...@apache.org>
Committed: Fri Feb 24 08:40:37 2012 +0100

----------------------------------------------------------------------
 .../org/apache/wicket/ajax/AjaxEventBehavior.java  |   23 +++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/72b6f637/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
index ca42719..2b78c3d 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
@@ -21,6 +21,8 @@ import org.apache.wicket.IClusterable;
 import org.apache.wicket.markup.ComponentTag;
 import org.apache.wicket.util.string.Strings;
 import org.apache.wicket.util.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * An ajax behavior that is attached to a certain client-side (usually javascript) event, such as
@@ -48,6 +50,8 @@ import org.apache.wicket.util.time.Duration;
  */
 public abstract class AjaxEventBehavior extends AbstractDefaultAjaxBehavior
 {
+	private static final Logger LOG = LoggerFactory.getLogger(AjaxEventBehavior.class);
+
 	private static long sequence = 0;
 
 	private static final long serialVersionUID = 1L;
@@ -108,6 +112,20 @@ public abstract class AjaxEventBehavior extends AbstractDefaultAjaxBehavior
 		Component myComponent = getComponent();
 		if (myComponent.isEnabledInHierarchy())
 		{
+			if (LOG.isWarnEnabled() && myComponent.getApplication().usesDevelopmentConfig())
+			{
+				String attribute = tag.getAttribute(event);
+				if (Strings.isEmpty(attribute) == false)
+				{
+					LOG.warn("{} assigned to {} is overriding the previous value of the inline attribute. " +
+						"Maybe there are several Ajax event behaviors on the same type assigned to this component.",
+						new Object[] {
+							this, myComponent
+						}
+					);
+				}
+			}
+
 			tag.put(event, getEventHandler());
 		}
 	}
@@ -173,6 +191,11 @@ public abstract class AjaxEventBehavior extends AbstractDefaultAjaxBehavior
 	 */
 	protected abstract void onEvent(final AjaxRequestTarget target);
 
+	@Override
+	public String toString()
+	{
+		return getClass().getName() + " {" + "event='" + event + '\'' + '}';
+	}
 
 	/**
 	 * Class to keep track of throttling settings.