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 2011/01/04 12:14:43 UTC
svn commit: r1054974 - in
/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/ajax/form:
AjaxFormChoiceComponentUpdatingBehavior.java
AjaxFormComponentUpdatingBehavior.java
Author: pedro
Date: Tue Jan 4 11:14:43 2011
New Revision: 1054974
URL: http://svn.apache.org/viewvc?rev=1054974&view=rev
Log:
just removing duplicated code
Issue: WICKET-3275
Modified:
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java
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/AjaxFormChoiceComponentUpdatingBehavior.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java?rev=1054974&r1=1054973&r2=1054974&view=diff
==============================================================================
--- wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java (original)
+++ wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java Tue Jan 4 11:14:43 2011
@@ -16,6 +16,7 @@
*/
package org.apache.wicket.ajax.form;
+import org.apache.wicket.Component;
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
@@ -120,9 +121,7 @@ public abstract class AjaxFormChoiceComp
{
super.onBind();
- if (!(getComponent() instanceof RadioChoice) &&
- !(getComponent() instanceof CheckBoxMultipleChoice) &&
- !(getComponent() instanceof RadioGroup) && !(getComponent() instanceof CheckGroup))
+ if (!AjaxFormChoiceComponentUpdatingBehavior.appliesTo(getComponent()))
{
throw new WicketRuntimeException("Behavior " + getClass().getName() +
" can only be added to an instance of a RadioChoice/CheckboxChoice/RadioGroup/CheckGroup");
@@ -186,4 +185,15 @@ public abstract class AjaxFormChoiceComp
}
}
+
+ /**
+ * @param component
+ * @return if the component applies to the {@link AjaxFormChoiceComponentUpdatingBehavior}
+ */
+ static boolean appliesTo(Component component)
+ {
+ return (component instanceof RadioChoice) ||
+ (component instanceof CheckBoxMultipleChoice) || (component instanceof RadioGroup) ||
+ (component instanceof CheckGroup);
+ }
}
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=1054974&r1=1054973&r2=1054974&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 Tue Jan 4 11:14:43 2011
@@ -20,11 +20,7 @@ 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;
@@ -85,9 +81,7 @@ public abstract class AjaxFormComponentU
" 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)))
+ AjaxFormChoiceComponentUpdatingBehavior.appliesTo(getComponent()))
{
log.warn(String.format(
"AjaxFormComponentUpdatingBehavior is not suposed to be added in the form component at path: \"%s\". "