org.apache.struts.validator

Class DynaValidatorForm

public class DynaValidatorForm extends DynaActionForm implements 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.

Since: Struts 1.1

Version: $Rev: 164862 $ $Date: 2005-04-26 20:08:32 +0100 (Tue, 26 Apr 2005) $

See Also: ActionForm

Field Summary
static Loglog
Commons Logging instance.
protected intpage
Used to indicate the current page of a multi-page form.
protected ValidatorResultsvalidatorResults
The results returned from the validation performed by the Validator.
Method Summary
intgetPage()
Gets page.
MapgetResultValueMap()
Returns a Map of values returned from any validation that returns a value other than null or Boolean with the key the full property path of the field.
StringgetValidationKey(ActionMapping mapping, HttpServletRequest request)
Returns the Validation key.
ValidatorResultsgetValidatorResults()
Get results of the validation performed by the Validator.
voidreset(ActionMapping mapping, HttpServletRequest request)
Reset all properties to their default values.
voidsetPage(int page)
Sets page.
protected voidsetPageFromDynaProperty()
Sets this.page to the value of the Dyna property "page" if it's defined.
voidsetValidatorResults(ValidatorResults validatorResults)
Set results of the validation performed by the Validator.
ActionErrorsvalidate(ActionMapping mapping, HttpServletRequest request)
Validate the properties that have been set from this HTTP request, and return an ActionErrors object that encapsulates any validation errors that have been found.

Field Detail

log

private static Log log
Commons Logging instance.

page

protected int page
Used to indicate the current page of a multi-page form.

validatorResults

protected ValidatorResults validatorResults
The results returned from the validation performed by the Validator.

Method Detail

getPage

public int getPage()
Gets page.

Returns: page number.

getResultValueMap

public Map getResultValueMap()
Returns a Map of values returned from any validation that returns a value other than null or Boolean with the key the full property path of the field.

Returns: Returns a Map of values, otherwise returns null if no results.

getValidationKey

public String getValidationKey(ActionMapping mapping, HttpServletRequest request)
Returns the Validation key.

Parameters: mapping The mapping used to select this instance request The servlet request we are processing

Returns: validation key - the form element's name in this case

getValidatorResults

public ValidatorResults getValidatorResults()
Get results of the validation performed by the Validator.

Returns: validator results as ValidatorResults object

reset

public void reset(ActionMapping mapping, HttpServletRequest request)
Reset all properties to their default values.

Parameters: mapping The mapping used to select this instance request The servlet request we are processing

setPage

public void setPage(int page)
Sets page.

Parameters: page page number

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

setValidatorResults

public void setValidatorResults(ValidatorResults validatorResults)
Set results of the validation performed by the Validator.

Parameters: validatorResults Set results of the validation performed

validate

public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
Validate the properties that have been set from this HTTP request, and return an ActionErrors object that encapsulates any validation errors that have been found. If no errors are found, return null or an ActionErrors object with no recorded error messages.

Parameters: mapping The mapping used to select this instance. request The servlet request we are processing.

Returns: ActionErrors object that encapsulates any validation errors.

Copyright B) 2000-2009 - The Apache Software Foundation