Class BeanValidatorForm
- All Implemented Interfaces:
Serializable
,org.apache.commons.beanutils.DynaBean
- Direct Known Subclasses:
LazyValidatorForm
Struts validator ActionForm
backed by either a
DynaBean
or POJO JavaBean.
Passing a POJO JavaBean to the constructor will automatically create an
associated WrapDynaBean
. One use for this would be to migrate
view objects from an existing system which, for the usual reasons,
can't be changed to extend ActionForm
.
This form is based on the standard struts ValidatorForm
for
use with the Validator framework and validates either using the
name from the Struts ActionMapping
or the
ActionMapping
's path depending on whether
pathValidation
is true
or
false
.
Note: WrapDynaBean is NOT serializable. If you use this class with a WrapDynaBean (as described above), you should not store your form in session scope.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.apache.commons.beanutils.DynaBean
TheDynaBean
that this ActionForm is backed by.protected boolean
Indicates whether the ActionMapping's path should be used for the validation key.Fields inherited from class org.apache.struts.validator.ValidatorForm
page, validatorResults
Fields inherited from class org.apache.struts.action.ActionForm
multipartRequestHandler, servlet
-
Constructor Summary
ConstructorDescriptionBeanValidatorForm
(Object bean) Construct a newBeanValidatorForm
with the specified bean. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Does the specified mapped property contain a value for the specified key value?Return the value of a simple property with the specified name.Return the value of an indexed property with the specified name.Return the value of a mapped property with the specified name, ornull
if there is no value for the specified key.org.apache.commons.beanutils.DynaBean
Return theDynaBean
that thisActionForm
is backed by.org.apache.commons.beanutils.DynaClass
Return theDynaClass
instance that describes the set of properties available for this DynaBean.Return theBean
that thisActionForm
is backed by.Return name used to identify the ActionForm in the struts-config.xml.getValidationKey
(ActionMapping mapping, HttpServletRequest request) Returns the Validation keyvoid
initialize
(FormBeanConfig formBeanConfig) Perform intialization of the ActionForm.protected boolean
Indicates whether this form should validate based on theActionMapping
's path.void
Remove any existing value for the specified key on the specified mapped property.void
Set the value of an indexed property with the specified name.void
Set the value of a simple property with the specified name.void
Set the value of a mapped property with the specified name.protected void
setPathValidation
(boolean pathValidation) Set whether this form should validate based on theActionMapping
's path.int
Return the size of an indexed or mapped property.Methods inherited from class org.apache.struts.validator.ValidatorForm
determinePage, getPage, getResultValueMap, getValidatorResults, reset, setPage, setValidatorResults, validate
Methods inherited from class org.apache.struts.action.ActionForm
getMultipartRequestHandler, getServlet, getServletWrapper, reset, setMultipartRequestHandler, setServlet, validate
-
Field Details
-
dynaBean
protected org.apache.commons.beanutils.DynaBean dynaBeanTheDynaBean
that this ActionForm is backed by. -
pathValidation
protected boolean pathValidationIndicates whether the ActionMapping's path should be used for the validation key.
-
-
Constructor Details
-
BeanValidatorForm
Construct a newBeanValidatorForm
with the specified bean.
-
-
Method Details
-
setPathValidation
protected void setPathValidation(boolean pathValidation) Set whether this form should validate based on the
ActionMapping
's path. -
isPathValidation
protected boolean isPathValidation()Indicates whether this form should validate based on the
ActionMapping
's path. -
initialize
Perform intialization of the ActionForm.
This method is called when the form is created.
- Since:
- Struts 1.3.6
-
getStrutsConfigFormName
Return name used to identify the ActionForm in the struts-config.xml.- Since:
- Struts 1.3.6
-
getDynaBean
public org.apache.commons.beanutils.DynaBean getDynaBean()Return the
DynaBean
that thisActionForm
is backed by. -
getInstance
Return the
Bean
that thisActionForm
is backed by.If the
DynaBean
is aWrapDynaBean
type then this method returns the 'Wrapped' POJO bean associated with it. If you require the actualWrapDynaBean
then use thegetDynaBean()
method. -
size
Return the size of an indexed or mapped property.
-
getValidationKey
Returns the Validation key- Overrides:
getValidationKey
in classValidatorForm
- Parameters:
mapping
- The mapping used to select this instancerequest
- The servlet request we are processing- Returns:
- validation key to use
-
getDynaClass
public org.apache.commons.beanutils.DynaClass getDynaClass()Return theDynaClass
instance that describes the set of properties available for this DynaBean.- Specified by:
getDynaClass
in interfaceorg.apache.commons.beanutils.DynaBean
-
get
Return the value of a simple property with the specified name.- Specified by:
get
in interfaceorg.apache.commons.beanutils.DynaBean
- Parameters:
name
- Name of the property whose value is to be retrieved
-
get
Return the value of an indexed property with the specified name.- Specified by:
get
in interfaceorg.apache.commons.beanutils.DynaBean
- Parameters:
name
- Name of the property whose value is to be retrievedindex
- Index of the value to be retrieved
-
get
Return the value of a mapped property with the specified name, ornull
if there is no value for the specified key.- Specified by:
get
in interfaceorg.apache.commons.beanutils.DynaBean
- Parameters:
name
- Name of the property whose value is to be retrievedkey
- Key of the value to be retrieved
-
set
Set the value of a simple property with the specified name.- Specified by:
set
in interfaceorg.apache.commons.beanutils.DynaBean
- Parameters:
name
- Name of the property whose value is to be setvalue
- Value to which this property is to be set
-
set
Set the value of an indexed property with the specified name.- Specified by:
set
in interfaceorg.apache.commons.beanutils.DynaBean
- Parameters:
name
- Name of the property whose value is to be setindex
- Index of the property to be setvalue
- Value to which this property is to be set
-
set
Set the value of a mapped property with the specified name.- Specified by:
set
in interfaceorg.apache.commons.beanutils.DynaBean
- Parameters:
name
- Name of the property whose value is to be setkey
- Key of the property to be setvalue
- Value to which this property is to be set
-
contains
Does the specified mapped property contain a value for the specified key value?- Specified by:
contains
in interfaceorg.apache.commons.beanutils.DynaBean
- Parameters:
name
- Name of the property to checkkey
- Name of the key to check
-
remove
Remove any existing value for the specified key on the specified mapped property.- Specified by:
remove
in interfaceorg.apache.commons.beanutils.DynaBean
- Parameters:
name
- Name of the property for which a value is to be removedkey
- Key of the value to be removed
-