You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by iv...@apache.org on 2010/09/07 02:51:59 UTC

svn commit: r993187 - /wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java

Author: ivaynberg
Date: Tue Sep  7 00:51:59 2010
New Revision: 993187

URL: http://svn.apache.org/viewvc?rev=993187&view=rev
Log:

Issue: WICKET-1743

Modified:
    wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java

Modified: wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java?rev=993187&r1=993186&r2=993187&view=diff
==============================================================================
--- wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java (original)
+++ wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java Tue Sep  7 00:51:59 2010
@@ -773,10 +773,6 @@ public class BaseWicketTester extends Mo
 
 			AjaxSubmitLink link = (AjaxSubmitLink)linkComponent;
 
-			String inputName = ((IFormSubmittingComponent)link).getInputName();
-			Map<String, String[]> requestParams = getParametersForNextRequest();
-			requestParams.put(inputName, new String[] { "x" });
-
 			// We cycle through the attached behaviors and select the
 			// LAST matching behavior as the one we handle.
 			List<IBehavior> behaviors = link.getBehaviors();
@@ -1376,15 +1372,33 @@ public class BaseWicketTester extends Mo
 
 		String failMessage = "No form attached to the submitlink.";
 		notNull(failMessage, form);
+		/*
+		 * Means that an button or an ajax link was clicked and needs to be added to the request
+		 * parameters to their form component correctly resolves the submit origin
+		 */
+		if (component instanceof Button)
+		{
+			Button clickedButton = (Button)component;
+			getServletRequest().setParameter(clickedButton.getInputName(), clickedButton.getValue());
+		}
+		else if (component instanceof AjaxSubmitLink)
+		{
+			String inputName = ((IFormSubmittingComponent)component).getInputName();
+			Map<String, String[]> requestParams = getParametersForNextRequest();
+			requestParams.put(inputName, new String[] { "x" });
+		}
 
 		form.visitFormComponents(new FormComponent.AbstractVisitor()
 		{
 			@Override
 			public void onFormComponent(FormComponent<?> formComponent)
 			{
+				/*
+				 * It is important to don't add every button input name as an request parameter to
+				 * respect the submit origin
+				 */
 				if (!(formComponent instanceof RadioGroup) &&
-					!(formComponent instanceof CheckGroup) &&
-					!formComponent.getClass().isAssignableFrom(Button.class) &&
+					!(formComponent instanceof CheckGroup) && !(formComponent instanceof Button) &&
 					formComponent.isVisibleInHierarchy() && formComponent.isEnabledInHierarchy())
 				{
 					if (!((formComponent instanceof IFormSubmittingComponent) && (component instanceof IFormSubmittingComponent)) ||