You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by pa...@apache.org on 2020/01/24 14:53:43 UTC
[wicket] 01/02: WICKET-6731: move inline onclick to event handler
This is an automated email from the ASF dual-hosted git repository.
papegaaij pushed a commit to branch csp-submitlink
in repository https://gitbox.apache.org/repos/asf/wicket.git
commit a6ed6f294707ecd6606b089b074a3098b4add6c3
Author: Emond Papegaaij <em...@topicus.nl>
AuthorDate: Fri Jan 24 14:50:02 2020 +0100
WICKET-6731: move inline onclick to event handler
---
.../apache/wicket/markup/html/form/SubmitLink.java | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/SubmitLink.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/SubmitLink.java
index 30cbe8b..d8c9426 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/SubmitLink.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/SubmitLink.java
@@ -17,7 +17,10 @@
package org.apache.wicket.markup.html.form;
import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.model.IModel;
+import org.apache.wicket.util.string.AppendingStringBuffer;
/**
* A link which can be used exactly like a Button to submit a Form. The onclick of the link will use
@@ -165,21 +168,31 @@ public class SubmitLink extends AbstractSubmitLink
if (tag.getName().equalsIgnoreCase("a") || tag.getName().equalsIgnoreCase("link")
|| tag.getName().equalsIgnoreCase("area"))
{
- tag.put("href", "javascript:;");
+ tag.put("href", "#");
}
else if (tag.getName().equalsIgnoreCase("button"))
{
// WICKET-5597 prevent default submit
tag.put("type", "button");
}
-
- tag.put("onclick", getTriggerJavaScript());
}
else
{
disableLink(tag);
}
}
+
+ @Override
+ public void renderHead(IHeaderResponse response)
+ {
+ super.renderHead(response);
+
+ if (isEnabledInHierarchy())
+ {
+ response.render(OnDomReadyHeaderItem.forScript("Wicket.Event.add('" + getMarkupId()
+ + "', 'click', function(event) { " + getTriggerJavaScript() + " });"));
+ }
+ }
/**
* Controls whether or not clicking on this link will invoke form's javascript onsubmit handler.