Package org.apache.struts.validator
Class DynaValidatorForm
java.lang.Object
org.apache.struts.action.ActionForm
org.apache.struts.action.DynaActionForm
org.apache.struts.validator.DynaValidatorForm
- All Implemented Interfaces:
Serializable
,org.apache.commons.beanutils.DynaBean
- Direct Known Subclasses:
DynaValidatorActionForm
public class DynaValidatorForm
extends DynaActionForm
implements org.apache.commons.beanutils.DynaBean, Serializable
This class extends DynaActionForm and provides basic field validation based on an XML file. The key passed into the validator is the action element's 'name' attribute from the struts-config.xml which should match the form element's name attribute in the validation.xml.
- See
ValidatorPlugin
definition in struts-config.xml for validation rules.
- Since:
- Struts 1.1
- Version:
- $Rev$ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005) $
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
Used to indicate the current page of a multi-page form.protected org.apache.commons.validator.ValidatorResults
The results returned from the validation performed by theValidator
.Fields inherited from class org.apache.struts.action.DynaActionForm
dynaClass, dynaValues
Fields inherited from class org.apache.struts.action.ActionForm
multipartRequestHandler, servlet
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected int
determinePage
(ActionMapping mapping, HttpServletRequest request) Determine validation page.
If acceptPage of ActionMapping is null, then returns Integer.MAX_VALUE.int
getPage()
Gets page.Returns aMap
of values returned from any validation that returns a value other thannull
orBoolean
with the key the full property path of the field.getValidationKey
(ActionMapping mapping, HttpServletRequest request) Returns the Validation key.org.apache.commons.validator.ValidatorResults
Get results of the validation performed by theValidator
.void
reset
(ActionMapping mapping, HttpServletRequest request) Reset all properties to their default values.void
setPage
(int page) Sets page.protected void
Sets this.page to the value of the Dyna property "page" if it's defined.void
setValidatorResults
(org.apache.commons.validator.ValidatorResults validatorResults) Set results of the validation performed by theValidator
.validate
(ActionMapping mapping, HttpServletRequest request) Validate the properties that have been set from this HTTP request, and return anActionErrors
object that encapsulates any validation errors that have been found.Methods inherited from class org.apache.struts.action.DynaActionForm
contains, get, get, get, getDynaClass, getDynaProperty, getMap, getString, getStrings, initialize, initialize, isDynaAssignable, remove, reset, set, set, set, toString
Methods inherited from class org.apache.struts.action.ActionForm
getMultipartRequestHandler, getServlet, getServletWrapper, setMultipartRequestHandler, setServlet, validate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.commons.beanutils.DynaBean
contains, get, get, get, getDynaClass, remove, set, set, set
-
Field Details
-
validatorResults
protected org.apache.commons.validator.ValidatorResults validatorResultsThe results returned from the validation performed by theValidator
. -
page
protected int pageUsed to indicate the current page of a multi-page form.
-
-
Constructor Details
-
DynaValidatorForm
public DynaValidatorForm()
-
-
Method Details
-
getPage
public int getPage()Gets page.- Returns:
- page number.
-
setPage
public void setPage(int page) Sets page.- Parameters:
page
- page number
-
validate
Validate the properties that have been set from this HTTP request, and return anActionErrors
object that encapsulates any validation errors that have been found. If no errors are found, returnnull
or anActionErrors
object with no recorded error messages.- Overrides:
validate
in classActionForm
- Parameters:
mapping
- The mapping used to select this instance.request
- The servlet request we are processing.- Returns:
ActionErrors
object that encapsulates any validation errors.- See Also:
-
determinePage
Determine validation page.
If acceptPage of ActionMapping is null, then returns Integer.MAX_VALUE. (multi-page validation is disabled. All validation fields are enabled.)
If page property is less than acceptPage of ActionMapping, returns acceptPage value.
If page property is greater than or equal to acceptPage of ActionMapping, returns page property value.- Parameters:
mapping
- The mapping used to select this instance.request
- The servlet request we are processing.- Returns:
- validation page.
- Since:
- Struts 1.4.1
-
getValidationKey
Returns the Validation key.- Parameters:
mapping
- The mapping used to select this instancerequest
- The servlet request we are processing- Returns:
- validation key - the form element's name in this case
-
setPageFromDynaProperty
protected void setPageFromDynaProperty()Sets this.page to the value of the Dyna property "page" if it's defined. This is used to setup the page variable before validation starts.- Since:
- Struts 1.2
-
reset
Reset all properties to their default values.- Overrides:
reset
in classDynaActionForm
- Parameters:
mapping
- The mapping used to select this instancerequest
- The servlet request we are processing
-
getValidatorResults
public org.apache.commons.validator.ValidatorResults getValidatorResults()Get results of the validation performed by theValidator
.- Returns:
- validator results as ValidatorResults object
-
setValidatorResults
public void setValidatorResults(org.apache.commons.validator.ValidatorResults validatorResults) Set results of the validation performed by theValidator
.- Parameters:
validatorResults
- Set results of the validation performed
-
getResultValueMap
Returns aMap
of values returned from any validation that returns a value other thannull
orBoolean
with the key the full property path of the field.- Returns:
- Returns a
Map
of values, otherwise returns null if no results.
-