[cvs] expresso commit by rauld: added getter and setter methods for
validator
JCorporate Ltd
jcorp at jcorp2.servlets.net
Sat Dec 4 03:01:53 PST 2004
Log Message:
-----------
added getter and setter methods for validator properties as in ValidatorForm
Modified Files:
--------------
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/controller:
DefaultForm.java
Revision Data
-------------
Index: DefaultForm.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/controller/DefaultForm.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/controller/DefaultForm.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/controller/DefaultForm.java -u -r1.16 -r1.17
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/controller/DefaultForm.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/controller/DefaultForm.java
@@ -86,6 +86,8 @@
import java.util.Iterator;
import java.util.Locale;
import java.util.StringTokenizer;
+import java.util.Map;
+import org.apache.struts.util.RequestUtils;
/**
@@ -232,6 +234,7 @@
return errors;
}
+
/**
* Validate the properties that have been set from this HTTP request,
* and return an <code>ActionErrors</code> object that encapsulates any
@@ -409,27 +412,87 @@
ActionErrors errors,
int page) {
- ValidatorResources resources = Resources.getValidatorResources(application,
- request);
- Locale locale = Resources.getLocale(request);
+ ValidatorResources resources =
+ Resources.getValidatorResources(application, request);
+
+ Locale locale = RequestUtils.getUserLocale(request, null);
Validator validator = new Validator(resources, key);
validator.setUseContextClassLoader(true);
validator.setPage(page);
- validator.addResource(Resources.
- SERVLET_CONTEXT_KEY, application);
- validator.addResource(Resources.
- HTTP_SERVLET_REQUEST_KEY, request);
- validator.addResource(Validator.LOCALE_KEY, locale);
- validator.addResource(Resources.
- ACTION_ERRORS_KEY, errors);
- validator.addResource(Validator.BEAN_KEY, bean);
+ validator.setParameter(Resources.SERVLET_CONTEXT_KEY, application);
+ validator.setParameter(Resources.HTTP_SERVLET_REQUEST_KEY, request);
+ validator.setParameter(Validator.LOCALE_PARAM, locale);
+ validator.setParameter(Resources.ACTION_ERRORS_KEY, errors);
+ validator.setParameter(Validator.BEAN_PARAM, bean);
return validator;
+
+ }
+
+ /**
+ * Get results of the validation performed by the
+ * <code>Validator</code>.
+ * @return results of the validation
+ */
+ public ValidatorResults getValidatorResults() {
+ return validatorResults;
+ }
+
+ /**
+ * Set results of the validation performed by the
+ * <code>Validator</code>.
+ * @param validatorResults results of validation
+ */
+ 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.
+ * @return <code>Map</code> of non-null values
+ */
+ public Map getResultValueMap() {
+ return (validatorResults != null ? validatorResults.getResultValueMap() : null);
+ }
+
+ /**
+ * Gets page.
+ * @return page number
+ */
+ public int getPage() {
+ return page;
+ }
+
+ /**
+ * Sets page.
+ * @param page page number
+ */
+ public void setPage(int page) {
+ this.page = page;
+ }
+
+
+ /**
+ * Reset all properties to their default values.
+ *
+ * @param mapping The mapping used to select this instance
+ * @param request The servlet request we are processing
+ */
+ public void reset(ActionMapping mapping, HttpServletRequest request) {
+ super.reset(mapping, request);
+ page = 0;
+ validatorResults = null;
}
+
+
+
/**
* Used to indicate the current page of a multi-page form.
More information about the cvs
mailing list