You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by pe...@apache.org on 2010/12/20 18:45:28 UTC

svn commit: r1051222 - /wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java

Author: pedro
Date: Mon Dec 20 17:45:27 2010
New Revision: 1051222

URL: http://svn.apache.org/viewvc?rev=1051222&view=rev
Log:
Log a warn when an AjaxFormComponentUpdatingBehavior is added to an choice component
Issue: WICKET-3275

Modified:
    wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java

Modified: wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java?rev=1051222&r1=1051221&r2=1051222&view=diff
==============================================================================
--- wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java (original)
+++ wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java Mon Dec 20 17:45:27 2010
@@ -16,13 +16,20 @@
  */
 package org.apache.wicket.ajax.form;
 
+import org.apache.wicket.Application;
 import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.ajax.AjaxEventBehavior;
 import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.markup.html.form.CheckBoxMultipleChoice;
+import org.apache.wicket.markup.html.form.CheckGroup;
 import org.apache.wicket.markup.html.form.FormComponent;
+import org.apache.wicket.markup.html.form.RadioChoice;
+import org.apache.wicket.markup.html.form.RadioGroup;
 import org.apache.wicket.markup.html.form.persistence.IValuePersister;
 import org.apache.wicket.markup.html.form.validation.IFormValidator;
 import org.apache.wicket.util.string.AppendingStringBuffer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A behavior that updates the hosting FormComponent via ajax when an event it is attached to is
@@ -45,6 +52,8 @@ import org.apache.wicket.util.string.App
  */
 public abstract class AjaxFormComponentUpdatingBehavior extends AjaxEventBehavior
 {
+	private static final Logger log = LoggerFactory.getLogger(AjaxFormComponentUpdatingBehavior.class);
+
 	/**
 	 * 
 	 */
@@ -75,6 +84,16 @@ public abstract class AjaxFormComponentU
 			throw new WicketRuntimeException("Behavior " + getClass().getName() +
 				" can only be added to an instance of a FormComponent");
 		}
+		else if (Application.get().getConfigurationType().equals(Application.DEVELOPMENT) &&
+			((getComponent() instanceof RadioChoice) ||
+				(getComponent() instanceof CheckBoxMultipleChoice) ||
+				(getComponent() instanceof RadioGroup) || (getComponent() instanceof CheckGroup)))
+		{
+			log.warn(String.format(
+				"AjaxFormComponentUpdatingBehavior is not suposed to be added in the form component at path: \"%s\". "
+					+ "Use the AjaxFormChoiceComponentUpdatingBehavior instead, that is meant for choices/groups that are not one component in the html but many",
+				getComponent().getPageRelativePath()));
+		}
 	}
 
 	/**