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/07/24 16:48:47 UTC
[2/2] git commit: WICKET-4641 AjaxFallbackLink and log a warning when
there are several ajax event behaviors on the same event
WICKET-4641 AjaxFallbackLink and log a warning when there are several ajax event behaviors on the same event
Conflicts:
wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/AjaxFallbackLink.java
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/fbabde2e
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/fbabde2e
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/fbabde2e
Branch: refs/heads/master
Commit: fbabde2eef012653751961cee7a3b875a2cff613
Parents: a4437e6
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Tue Jul 24 16:28:53 2012 +0300
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Tue Jul 24 17:47:25 2012 +0300
----------------------------------------------------------------------
.../wicket/ajax/markup/html/AjaxFallbackLink.java | 22 +++++++++++++--
1 files changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/fbabde2e/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/AjaxFallbackLink.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/AjaxFallbackLink.java b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/AjaxFallbackLink.java
index 702fdc8..7e2a6e2 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/AjaxFallbackLink.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/AjaxFallbackLink.java
@@ -24,11 +24,14 @@ import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.model.IModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* An ajax link that will degrade to a normal request if ajax is not available or javascript is
* disabled.
- * <p>
+ *
+ * <p>
* If JavaScript is enabled then the registered JavaScript event 'click' handler will be used,
* otherwise the 'href' attribute if the markup element is an <a>, <area> or <link>.
* AjaxFallbackLink doesn't fallback if the markup element is none of the three above.
@@ -42,6 +45,8 @@ import org.apache.wicket.model.IModel;
*/
public abstract class AjaxFallbackLink<T> extends Link<T> implements IAjaxLink
{
+ private static final Logger LOG = LoggerFactory.getLogger(AjaxFallbackLink.class);
+
/** */
private static final long serialVersionUID = 1L;
@@ -170,7 +175,18 @@ public abstract class AjaxFallbackLink<T> extends Link<T> implements IAjaxLink
// Ajax links work with JavaScript Event registration
tag.remove("onclick");
- }
-
+ String tagName = tag.getName();
+ if (
+ LOG.isWarnEnabled() &&
+ !("a".equalsIgnoreCase(tagName) || "area".equalsIgnoreCase(tagName) || "link".equalsIgnoreCase(tagName))
+ )
+ {
+ String msg = String.format("%s must be used only with <a>, <area> or <link> markup elements. " +
+ "The fallback functionality doesn't work for other markup elements. " +
+ "Component path: %s, markup element: <%s>.",
+ AjaxFallbackLink.class.getSimpleName(), getClassRelativePath(), tagName);
+ findMarkupStream().throwMarkupException(msg);
+ }
+ }
}