dgraham 2003/04/03 22:41:09 Modified: src/share/org/apache/struts/taglib/html JavascriptValidatorTag.java Log: Don't output requiredif field* javascript variables because they're not used and break other validations. PR # 18018. Revision Changes Path 1.25 +22 -17 jakarta-struts/src/share/org/apache/struts/taglib/html/JavascriptValidatorTag.java Index: JavascriptValidatorTag.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/JavascriptValidatorTag.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- JavascriptValidatorTag.java 10 Mar 2003 01:57:31 -0000 1.24 +++ JavascriptValidatorTag.java 4 Apr 2003 06:41:09 -0000 1.25 @@ -320,8 +320,7 @@ locale = defaultLocale; } - Form form = null; - form = resources.get(locale, formName); + Form form = resources.get(locale, formName);; if (form != null) { if ("true".equals(dynamicJavascript)) { MessageResources messages = @@ -438,47 +437,52 @@ results.append("new Function (\"varName\", \""); - Map hVars = field.getVars(); + Map vars = field.getVars(); // Loop through the field's variables. - for (Iterator iVars = hVars.keySet().iterator(); iVars.hasNext();) { - String varKey = (String) iVars.next(); - Var var = (Var) hVars.get(varKey); + for (Iterator varsIterator = vars.keySet().iterator(); varsIterator.hasNext();) { + String varName = (String) varsIterator.next(); + Var var = (Var) vars.get(varName); String varValue = var.getValue(); String jsType = var.getJsType(); + + // skip requiredif variables field, fieldIndexed, fieldTest, fieldValue + if (varName.startsWith("field")){ + continue; + } if (Var.JSTYPE_INT.equalsIgnoreCase(jsType)) { results.append( "this." - + varKey + + varName + "=" + ValidatorUtil.replace(varValue, "\\", "\\\\") + "; "); } else if (Var.JSTYPE_REGEXP.equalsIgnoreCase(jsType)) { results.append( "this." - + varKey + + varName + "=/" + ValidatorUtil.replace(varValue, "\\", "\\\\") + "/; "); } else if (Var.JSTYPE_STRING.equalsIgnoreCase(jsType)) { results.append( "this." - + varKey + + varName + "='" + ValidatorUtil.replace(varValue, "\\", "\\\\") + "'; "); // So everyone using the latest format doesn't need to change their xml files immediately. - } else if ("mask".equalsIgnoreCase(varKey)) { + } else if ("mask".equalsIgnoreCase(varName)) { results.append( "this." - + varKey + + varName + "=/" + ValidatorUtil.replace(varValue, "\\", "\\\\") + "/; "); } else { results.append( "this." - + varKey + + varName + "='" + ValidatorUtil.replace(varValue, "\\", "\\\\") + "'; "); @@ -492,8 +496,9 @@ } } else if ("true".equals(staticJavascript)) { results.append(this.getStartElement()); - if ("true".equals(htmlComment)) + if ("true".equals(htmlComment)) { results.append(htmlBeginComment); + } } } if ("true".equals(staticJavascript)) {
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]