You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by sa...@apache.org on 2010/06/20 15:51:46 UTC
svn commit: r956359 - in /click/trunk/click/extras/src:
META-INF/resources/click/checklist/checklist.js
org/apache/click/extras/control/CheckList.java
Author: sabob
Date: Sun Jun 20 13:51:45 2010
New Revision: 956359
URL: http://svn.apache.org/viewvc?rev=956359&view=rev
Log:
removed CheckList validation dependence on Form name
Modified:
click/trunk/click/extras/src/META-INF/resources/click/checklist/checklist.js
click/trunk/click/extras/src/org/apache/click/extras/control/CheckList.java
Modified: click/trunk/click/extras/src/META-INF/resources/click/checklist/checklist.js
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/META-INF/resources/click/checklist/checklist.js?rev=956359&r1=956358&r2=956359&view=diff
==============================================================================
--- click/trunk/click/extras/src/META-INF/resources/click/checklist/checklist.js (original)
+++ click/trunk/click/extras/src/META-INF/resources/click/checklist/checklist.js Sun Jun 20 13:51:45 2010
@@ -15,10 +15,10 @@
* See Nicolaus Rougeux 'Check it, don't select it':
* http://c82.net/article.php?ID=25
*/
-function initChecklist(checklistid) {
+function initChecklist(checkListId) {
if (document.all && document.getElementById) {
// Get all unordered lists
- var theList = document.getElementById(checklistid);
+ var theList = document.getElementById(checkListId);
if(theList != null) {
var labels = theList.getElementsByTagName("label");
@@ -32,13 +32,17 @@ function initChecklist(checklistid) {
}
}
-function validateCheckList(pathName, required, msgs){
+function validateCheckList(checkListName, formId, required, msgs){
if(required){
- for (i = 0; i < pathName.length; i++) {
- if (pathName[i].checked) {
- return null;
- }
- }
- return msgs[0];
+ var form = document.getElementById(formId);
+ if(form){
+ var path=form[checkListName];
+ for (i = 0; i < path.length; i++) {
+ if (path[i].checked) {
+ return null;
+ }
+ }
+ return msgs[0];
+ }
}
}
Modified: click/trunk/click/extras/src/org/apache/click/extras/control/CheckList.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/control/CheckList.java?rev=956359&r1=956358&r2=956359&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/control/CheckList.java (original)
+++ click/trunk/click/extras/src/org/apache/click/extras/control/CheckList.java Sun Jun 20 13:51:45 2010
@@ -192,15 +192,15 @@ public class CheckList extends Field {
* The field validation JavaScript function template.
* The function template arguments are: <ul>
* <li>0 - is the field id</li>
- * <li>1 - is the full path name to the checkbox</li>
- * <li>2 - is the Field required status</li>
- * <li>3 - is the localized error message for required validation</li>
+ * <li>1 - is the name of the checkbox</li>
+ * <li>2 - is the id of the form</li>
+ * <li>3 - is the Field required status</li>
+ * <li>4 - is the localized error message for required validation</li>
* </ul>
*/
protected final static String VALIDATE_CHECKLIST_FUNCTION =
"function validate_{0}() '{'\n"
- + " var msg = validateCheckList(\n"
- + " {1} ,{2}, [''{3}'']);\n"
+ + " var msg = validateCheckList(''{1}'', ''{2}'', {3}, [''{4}'']);\n"
+ " if (msg) '{'\n"
+ " return msg + ''|{0}'';\n"
+ " '}' else '{'\n"
@@ -904,11 +904,12 @@ public class CheckList extends Field {
*/
@Override
public String getValidationJavaScript() {
- Object[] args = new Object[4];
+ Object[] args = new Object[5];
args[0] = getId();
- args[1] = "document." + getForm().getName() + "." + getName();
- args[2] = String.valueOf(isRequired());
- args[3] = getMessage("field-required-error", getErrorLabel());
+ args[1] = getName();
+ args[2] = getForm().getId();
+ args[3] = String.valueOf(isRequired());
+ args[4] = getMessage("field-required-error", getErrorLabel());
return MessageFormat.format(VALIDATE_CHECKLIST_FUNCTION, args);
}