dwinterfeldt 02/04/01 20:02:13 Modified: src/share/org/apache/struts/validator DynaValidatorActionForm.java DynaValidatorForm.java ValidatorActionForm.java ValidatorForm.java Log: Adding access to ValidatorResults and the Map of any values returned from the validation methods processed by the Commons Validator. Revision Changes Path 1.3 +9 -2 jakarta-struts/src/share/org/apache/struts/validator/DynaValidatorActionForm.java Index: DynaValidatorActionForm.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/validator/DynaValidatorActionForm.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DynaValidatorActionForm.java 18 Mar 2002 05:14:27 -0000 1.2 +++ DynaValidatorActionForm.java 2 Apr 2002 04:02:13 -0000 1.3 @@ -1,4 +1,10 @@ /* + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/validator/DynaValidatorActionForm.java,v 1.3 2002/04/02 04:02:13 dwinterfeldt Exp $ + * $Revision: 1.3 $ + * $Date: 2002/04/02 04:02:13 $ + * + * ==================================================================== + * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights @@ -81,8 +87,9 @@ * <ul><li>See <code>ValidatorPlugin</code> definition in struts-config.xml * for validation rules.</li></ul> * - * @since 1.1 * @author David Winterfeldt + * @version $Revision: 1.3 $ $Date: 2002/04/02 04:02:13 $ + * @since 1.1 */ public class DynaValidatorActionForm extends DynaValidatorForm implements DynaBean, Serializable { @@ -114,7 +121,7 @@ errors, page); try { - validator.validate(); + validatorResults = validator.validate(); } catch (ValidatorException e) { log.error(e.getMessage(), e); } 1.2 +44 -2 jakarta-struts/src/share/org/apache/struts/validator/DynaValidatorForm.java Index: DynaValidatorForm.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/validator/DynaValidatorForm.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DynaValidatorForm.java 18 Mar 2002 01:42:51 -0000 1.1 +++ DynaValidatorForm.java 2 Apr 2002 04:02:13 -0000 1.2 @@ -1,4 +1,10 @@ /* + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/validator/DynaValidatorForm.java,v 1.2 2002/04/02 04:02:13 dwinterfeldt Exp $ + * $Revision: 1.2 $ + * $Date: 2002/04/02 04:02:13 $ + * + * ==================================================================== + * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights @@ -57,6 +63,7 @@ import java.io.Serializable; import java.util.Locale; +import java.util.Map; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import org.apache.commons.beanutils.DynaBean; @@ -65,6 +72,7 @@ import org.apache.commons.validator.Validator; import org.apache.commons.validator.ValidatorException; import org.apache.commons.validator.ValidatorResources; +import org.apache.commons.validator.ValidatorResults; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.DynaActionForm; import org.apache.struts.action.ActionMapping; @@ -81,8 +89,9 @@ * <ul><li>See <code>ValidatorPlugin</code> definition in struts-config.xml * for validation rules.</li></ul> * - * @since 1.1 * @author David Winterfeldt + * @version $Revision: 1.2 $ $Date: 2002/04/02 04:02:13 $ + * @since 1.1 * @see org.apache.struts.action.ActionForm */ @@ -94,6 +103,12 @@ private Log log = LogSource.getInstance(this.getClass().getName()); /** + * The results returned from the validation performed + * by the <code>Validator</code>. + */ + protected ValidatorResults validatorResults = null; + + /** * Used to indicate the current page of a multi-page form. */ protected int page = 0; @@ -134,7 +149,7 @@ errors, page); try { - validator.validate(); + validatorResults = validator.validate(); } catch (ValidatorException e) { log.error(e.getMessage(), e); } @@ -178,6 +193,33 @@ public void reset(ActionMapping mapping, HttpServletRequest request) { super.reset(mapping, request); page = 0; + validatorResults = null; + } + + /** + * Get results of the validation performed by the + * <code>Validator</code>. + */ + public ValidatorResults getValidatorResults() { + return validatorResults; + } + + /** + * Set results of the validation performed by the + * <code>Validator</code>. + */ + public void setValidatorResults(ValidatorResults validatorResults) { + this.validatorResults = validatorResults; + } + + /** + * Returns a <code>Map</code> of values returned + * from any validation that returns a value other than + * <code>null</code> or <code>Boolean</code> with the + * key the full property path of the field. + */ + public Map getResultValueMap() { + return (validatorResults != null ? validatorResults.getResultValueMap() : null); } } 1.2 +9 -2 jakarta-struts/src/share/org/apache/struts/validator/ValidatorActionForm.java Index: ValidatorActionForm.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/validator/ValidatorActionForm.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ValidatorActionForm.java 18 Mar 2002 01:42:51 -0000 1.1 +++ ValidatorActionForm.java 2 Apr 2002 04:02:13 -0000 1.2 @@ -1,4 +1,10 @@ /* + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/validator/ValidatorActionForm.java,v 1.2 2002/04/02 04:02:13 dwinterfeldt Exp $ + * $Revision: 1.2 $ + * $Date: 2002/04/02 04:02:13 $ + * + * ==================================================================== + * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights @@ -80,8 +86,9 @@ * <ul><li>See <code>ValidatorPlugin</code> definition in struts-config.xml * for validation rules.</li></ul> * - * @since 1.1 * @author David Winterfeldt + * @version $Revision: 1.2 $ $Date: 2002/04/02 04:02:13 $ + * @since 1.1 */ public class ValidatorActionForm extends ValidatorForm implements Serializable { @@ -113,7 +120,7 @@ errors, page); try { - validator.validate(); + validatorResults = validator.validate(); } catch (ValidatorException e) { log.error(e.getMessage(), e); } 1.2 +44 -2 jakarta-struts/src/share/org/apache/struts/validator/ValidatorForm.java Index: ValidatorForm.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/validator/ValidatorForm.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ValidatorForm.java 18 Mar 2002 01:42:51 -0000 1.1 +++ ValidatorForm.java 2 Apr 2002 04:02:13 -0000 1.2 @@ -1,4 +1,10 @@ /* + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/validator/ValidatorForm.java,v 1.2 2002/04/02 04:02:13 dwinterfeldt Exp $ + * $Revision: 1.2 $ + * $Date: 2002/04/02 04:02:13 $ + * + * ==================================================================== + * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights @@ -57,6 +63,7 @@ import java.io.Serializable; import java.util.Locale; +import java.util.Map; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import org.apache.commons.logging.Log; @@ -64,6 +71,7 @@ import org.apache.commons.validator.Validator; import org.apache.commons.validator.ValidatorException; import org.apache.commons.validator.ValidatorResources; +import org.apache.commons.validator.ValidatorResults; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; @@ -80,8 +88,9 @@ * <ul><li>See <code>ValidatorPlugin</code> definition in struts-config.xml * for validation rules.</li></ul> * - * @since 1.1 * @author David Winterfeldt + * @version $Revision: 1.2 $ $Date: 2002/04/02 04:02:13 $ + * @since 1.1 * @see org.apache.struts.action.ActionForm */ public class ValidatorForm extends ActionForm implements Serializable { @@ -92,6 +101,12 @@ private Log log = LogSource.getInstance(this.getClass().getName()); /** + * The results returned from the validation performed + * by the <code>Validator</code>. + */ + protected ValidatorResults validatorResults = null; + + /** * Used to indicate the current page of a multi-page form. */ protected int page = 0; @@ -132,7 +147,7 @@ errors, page); try { - validator.validate(); + validatorResults = validator.validate(); } catch (ValidatorException e) { log.error(e.getMessage(), e); } @@ -176,6 +191,33 @@ public void reset(ActionMapping mapping, HttpServletRequest request) { super.reset(mapping, request); page = 0; + validatorResults = null; } + /** + * Get results of the validation performed by the + * <code>Validator</code>. + */ + public ValidatorResults getValidatorResults() { + return validatorResults; + } + + /** + * Set results of the validation performed by the + * <code>Validator</code>. + */ + public void setValidatorResults(ValidatorResults validatorResults) { + this.validatorResults = validatorResults; + } + + /** + * Returns a <code>Map</code> of values returned + * from any validation that returns a value other than + * <code>null</code> or <code>Boolean</code> with the + * key the full property path of the field. + */ + public Map getResultValueMap() { + return (validatorResults != null ? validatorResults.getResultValueMap() : null); + } + }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>