[ http://issues.apache.org/struts/browse/STR-1520?page=all ] David Evans reopened STR-1520: ------------------------------
Assign To: (was: Rob Leland) > Validating all Fields. > ---------------------- > > Key: STR-1520 > URL: http://issues.apache.org/struts/browse/STR-1520 > Project: Struts Action 1 > Type: Improvement > Components: Taglibs > Versions: Nightly Build > Environment: Operating System: All > Platform: All > Reporter: Marcelo Caldas > Priority: Minor > Fix For: 1.2 Family > Attachments: JavascriptValidatorTagDiff.txt, JavascriptValidatorTagDiff.txt, > ValidatorPlugInDiff.txt > > One enhancement I added is to be able to validate all Rules instead of > stopping > at the first error found. This is very useful, depending on how you want to > present the error handling to the user - Alert pop-ups are not the most > efficient way. So, I created a Parameter on the ValidatorPlugIn.java, to > receive a boolean wheter it should stop validating at the first error > encountered (default behavior) or if it should validate all the way - no > matter > what. > Files modified for this enhancement: > org.apache.struts.validator.ValidatorPlugIn > org.apache.struts.taglib.html.JavascriptValidatorTag > Diffs (From RC2): > ValidatorPlugIn.java: > ===========================Init ValidatorPlugIn.java Diff > ===================== > 112a113,116> /** > > * Application scope key that <code>StopOnError</code> is stored under. > > */ > > public final static String STOP_ON_ERROR_KEY > = "org.apache.commons.validator.STOP_ON_ERROR"; > 142a147,168> /** > > * Informs the Validators if it has to stop validation when finding the > first Error > > * or if it should continue. > > * Default to true to keep backwards compatibility. > > */ > > private boolean stopOnFirstError = true; > > /** > > * Gets the value for stopOnFirstError. > > * @return a boolean indicating whether validator should stop when > finds the first error > > * or continue validation. > > */ > > public boolean isStopOnFirstError() { > > return stopOnFirstError; > > } > > /** > > * Sets the value for stopOnFirstError. > > * @param newValue a boolean indicating whether validator should stop > when finds the first error > > * or continue validation. > > */ > > public void setStopOnFirstError(boolean newValue) { > > this.stopOnFirstError = newValue; > > } > 164a191,193> servlet.getServletContext().setAttribute( > > STOP_ON_ERROR_KEY + config.getPrefix(), > > new Boolean(stopOnFirstError)); > ====================== End ValidatorPlugIn diff > =============================== > JavascriptValidatorTag: > ===================== Init JavascriptValidatorTag.java diff > =================== > 315a316,322> Object stopOnErrorObj = pageContext.getAttribute > (ValidatorPlugIn.STOP_ON_ERROR_KEY + config.getPrefix(), > > PageContext.APPLICATION_SCOPE); > > boolean stopOnError = true; > > if (stopOnErrorObj != null && (stopOnErrorObj instanceof Boolean)) { > > stopOnError = ((Boolean)stopOnErrorObj).booleanValue(); > > } > > > 390a398> if (stopOnError) { > 391a400,402> } else { > > methods += " & " + va.getMethod() + "(form)"; > > } > ==================== End JavascripValidatorTag diff > =========================== > Usage: > If you want the normal behavior provided by struts today - you don't have to > worry about any configuration - The default is to behave as of today - the > Javascript will stop when the first error is encountered. > If you want to validate all the way, you can set a new property on the > validator plug in tag on your struts-config.xml as follow: > <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> > <set-property property="pathnames" > value="/WEB-INF/validation.xml,/WEB-INF/validator- > rules.xml"/> > <set-property property="stopOnFirstError" value="true"/> > </plug-in> > If there's any questions or concerns, please send an e-mail to > [EMAIL PROTECTED] > Regards, > Marcelo Caldas -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/struts/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]