click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r956351 - in /click/trunk/click/framework/src: META-INF/resources/click/control.js org/apache/click/control/RadioGroup.java
Date Sun, 20 Jun 2010 12:32:53 GMT
Author: sabob
Date: Sun Jun 20 12:32:52 2010
New Revision: 956351

URL: http://svn.apache.org/viewvc?rev=956351&view=rev
Log:
removed RadioGroup validation dependence on Form name

Modified:
    click/trunk/click/framework/src/META-INF/resources/click/control.js
    click/trunk/click/framework/src/org/apache/click/control/RadioGroup.java

Modified: click/trunk/click/framework/src/META-INF/resources/click/control.js
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/META-INF/resources/click/control.js?rev=956351&r1=956350&r2=956351&view=diff
==============================================================================
--- click/trunk/click/framework/src/META-INF/resources/click/control.js (original)
+++ click/trunk/click/framework/src/META-INF/resources/click/control.js Sun Jun 20 12:32:52
2010
@@ -283,15 +283,18 @@ function validateSelect(id, defaultValue
     }
 }
 
-function validateRadioGroup(pathName, required, msgs) {
+function validateRadioGroup(radioName, formId, required, msgs) {
     if(required){
-        //var value = pathName.value;
-        for (i = 0; i < pathName.length; i++) {
-            if (pathName[i].checked) {
-                return null;
+        var form = document.getElementById(formId);
+        if(form){
+            var path=form[radioName];
+            for (i = 0; i < path.length; i++){
+                if (path[i].checked){
+                    return null;
+                }
             }
+            return msgs[0];
         }
-        return msgs[0];
     }
 }
 

Modified: click/trunk/click/framework/src/org/apache/click/control/RadioGroup.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/control/RadioGroup.java?rev=956351&r1=956350&r2=956351&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/control/RadioGroup.java (original)
+++ click/trunk/click/framework/src/org/apache/click/control/RadioGroup.java Sun Jun 20 12:32:52
2010
@@ -25,6 +25,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import org.apache.click.Context;
+import org.apache.click.util.ClickUtils;
 
 import org.apache.click.util.HtmlStringBuffer;
 import org.apache.click.util.PropertyUtils;
@@ -106,9 +107,9 @@ public class RadioGroup extends Field {
      */
     protected final static String VALIDATE_RADIOGROUP_FUNCTION =
         "function validate_{0}() '{'\n"
-        + "   var msg = validateRadioGroup({1}, {2}, [''{3}'']);\n"
+        + "   var msg = validateRadioGroup(''{1}'', ''{2}'', {3}, [''{4}'']);\n"
         + "   if (msg) '{'\n"
-        + "      return msg + ''|{4}'';\n"
+        + "      return msg + ''|{5}'';\n"
         + "   '}' else '{'\n"
         + "      return null;\n"
         + "   '}'\n"
@@ -381,17 +382,18 @@ public class RadioGroup extends Field {
      */
     @Override
     public String getValidationJavaScript() {
-        Object[] args = new Object[5];
+        Object[] args = new Object[6];
         args[0] = getId();
-        args[1] = "document." + getForm().getName() + "." + getName();
-        args[2] = String.valueOf(isRequired());
-        args[3] = getMessage("select-error", getErrorLabel());
+        args[1] = getName();
+        args[2] = getForm().getId();
+        args[3] = String.valueOf(isRequired());
+        args[4] = getMessage("select-error", getErrorLabel());
 
         if (!getRadioList().isEmpty()) {
             Radio radio = getRadioList().get(0);
-            args[4] = radio.getId();
+            args[5] = radio.getId();
         } else {
-            args[4] = "";
+            args[5] = "";
         }
 
         return MessageFormat.format(VALIDATE_RADIOGROUP_FUNCTION, args);
@@ -463,7 +465,7 @@ public class RadioGroup extends Field {
             try {
                 radio.onDestroy();
             } catch (Throwable t) {
-                t.printStackTrace();
+                ClickUtils.getLogService().error("onDestroy error", t);
             }
         }
     }



Mime
View raw message