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:42 UTC

[wicket] branch csp-submitlink created (now 2762db6)

This is an automated email from the ASF dual-hosted git repository.

papegaaij pushed a change to branch csp-submitlink
in repository https://gitbox.apache.org/repos/asf/wicket.git.


      at 2762db6  WICKET-6731: fixed tests

This branch includes the following new commits:

     new a6ed6f2  WICKET-6731: move inline onclick to event handler
     new 2762db6  WICKET-6731: fixed tests

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[wicket] 01/02: WICKET-6731: move inline onclick to event handler

Posted by pa...@apache.org.
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.


[wicket] 02/02: WICKET-6731: fixed tests

Posted by pa...@apache.org.
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 2762db6c8539b194aa7c0477e5d8bdb3d881a19d
Author: Emond Papegaaij <em...@topicus.nl>
AuthorDate: Fri Jan 24 15:49:37 2020 +0100

    WICKET-6731: fixed tests
---
 .../wicket/markup/html/form/validation/HomePage1_ExpectedResult.html    | 2 +-
 .../src/test/java/org/apache/wicket/stateless/StatelessFormUrlTest.java | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/validation/HomePage1_ExpectedResult.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/validation/HomePage1_ExpectedResult.html
index eb9e737..9f0e997 100644
--- a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/validation/HomePage1_ExpectedResult.html
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/validation/HomePage1_ExpectedResult.html
@@ -8,7 +8,7 @@
         <span wicket:id="message">If you see this message wicket is properly configured and running</span>
         
         <div wicket:id="bug"><wicket:panel>
-	<form wicket:id="form" id="form8" method="post" action="./org.apache.wicket.markup.html.form.validation.HomePage1?1-1.-bug-form">
+	<form wicket:id="form" id="form9" method="post" action="./org.apache.wicket.markup.html.form.validation.HomePage1?1-1.-bug-form">
 	  <div wicket:id="border"><wicket:border>
 		<wicket:body>
 	    <input wicket:id="name" value="" name="border:border_body:name"/>
diff --git a/wicket-core/src/test/java/org/apache/wicket/stateless/StatelessFormUrlTest.java b/wicket-core/src/test/java/org/apache/wicket/stateless/StatelessFormUrlTest.java
index ef30976..f2cd985 100644
--- a/wicket-core/src/test/java/org/apache/wicket/stateless/StatelessFormUrlTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/stateless/StatelessFormUrlTest.java
@@ -59,7 +59,7 @@ class StatelessFormUrlTest extends WicketTestCase
 	void submitLinkInputNameNotEncodedIntoFormAction()
 	{
 		tester.executeUrl("?0-1.IFormSubmitListener-form&text=newValue&submitLink=x");
-		assertEquals("./?-1.-form", tester.getTagById("form1").getAttribute("action"));
+		assertEquals("./?-1.-form", tester.getTagById("form2").getAttribute("action"));
 	}
 
 	/**