org.apache.struts.validator
Class ValidatorForm

java.lang.Object
  extended by org.apache.struts.action.ActionForm
      extended by org.apache.struts.validator.ValidatorForm
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BeanValidatorForm, ValidatorActionForm

public class ValidatorForm
extends ActionForm
implements Serializable

This class extends ActionForm 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: 471754 $ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005) $
See Also:
ActionForm, Serialized Form

Field Summary
protected  int page
          Used to indicate the current page of a multi-page form.
protected  ValidatorResults validatorResults
          The results returned from the validation performed by the Validator.
 
Fields inherited from class org.apache.struts.action.ActionForm
multipartRequestHandler, servlet
 
Constructor Summary
ValidatorForm()
           
 
Method Summary
 int getPage()
          Gets page.
 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.
 String getValidationKey(ActionMapping mapping, HttpServletRequest request)
          Returns the Validation key.
 ValidatorResults getValidatorResults()
          Get results of the validation performed by the Validator.
 void reset(ActionMapping mapping, HttpServletRequest request)
          Reset all properties to their default values.
 void setPage(int page)
          Sets page.
 void setValidatorResults(ValidatorResults validatorResults)
          Set results of the validation performed by the Validator.
 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.
 
Methods inherited from class org.apache.struts.action.ActionForm
getMultipartRequestHandler, getServlet, getServletWrapper, reset, setMultipartRequestHandler, setServlet, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

validatorResults

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


page

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

Constructor Detail

ValidatorForm

public ValidatorForm()
Method Detail

getPage

public int getPage()
Gets page.

Returns:
page number

setPage

public void setPage(int page)
Sets page.

Parameters:
page - page number

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.

Overrides:
validate in class ActionForm
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:
DynaActionForm

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

reset

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

Overrides:
reset in class ActionForm
Parameters:
mapping - The mapping used to select this instance
request - The servlet request we are processing

getValidatorResults

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

Returns:
results of the validation

setValidatorResults

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

Parameters:
validatorResults - results of validation

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:
Map of non-null values


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.