Author: pedro
Date: Tue Jan  4 11:14:38 2011
New Revision: 1054973

URL: http://svn.apache.org/viewvc?rev=1054973&view=rev
Log:
just removing duplicated code
Issue: WICKET-3275

Modified:
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java?rev=1054973&r1=1054972&r2=1054973&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java
 Tue Jan  4 11:14:38 2011
@@ -118,9 +118,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");
@@ -184,4 +182,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/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java?rev=1054973&r1=1054972&r2=1054973&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java
 Tue Jan  4 11:14:38 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.validation.IFormValidator;
 import org.apache.wicket.util.string.AppendingStringBuffer;
 import org.slf4j.Logger;
@@ -84,9 +80,7 @@ public abstract class AjaxFormComponentU
                                " can only be added to an instance of a 
FormComponent");
                }
                else if (Application.get().usesDevelopmentConfig() &&
-                       ((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\". "


Reply via email to