You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2003/02/27 12:37:11 UTC

DO NOT REPLY [Bug 17477] New: - All kind of validation should be done in generated javascript...

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17477>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17477

All kind of validation should be done in generated javascript...

           Summary: All kind of validation should be done in generated
                    javascript...
           Product: Struts
           Version: 1.1 Beta 3
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Minor
          Priority: Other
         Component: Validator Framework
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: lecerffreddy@fr.ibm.com


In the generated JavaScript for the validator, the following code could be 
found :

function validateMyForm(form) {
  if (bCancel)
    return true;
  else
    return validateMask(form) && validateRequired(form);
}

With this code if the validateMask() method return false, the validateRequired
() method isn't called.
If the form contains error of both type (mask and required), only the mask 
error would be displayed in the alert window.

In order to display all the encoutered error the class 
o.a.s.taglib.html.JavascriptValidatorTag could be modified as follow :



In the doStartTag() method, in the iterator loop, the following code :
if (methods == null) {
	methods = va.getMethod() + "(form)";
} else {
	methods += " && " + va.getMethod() + "(form)";
}

could be replaced by the following one:
if (methods == null) {
	methods = "          x" + index + " = " + va.getMethod() + "(form);\n";
} else {
	methods += "          x" + index + " = " + va.getMethod() + "(form);\n";
}
index++;



Just before this loop, the index variable as to be initialized to 0.



Just after this loop, the following code could be added:
methods += "          return ";
for (int index2=0 ; index2<index-1 ; index2++) {
	methods += "x" + index2 + " && ";
}
methods += "x" + (index-1) + ";\n";



In the getJavascriptBegin() method, the following line:
sb.append("        return " + methods + "; \n");

could be replaced by the following one:
sb.append("        { \n" + methods + "        } \n");

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org