public class BeanValidatorForm extends ValidatorForm implements org.apache.commons.beanutils.DynaBean, Serializable
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
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.
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.beanutils.DynaBean |
dynaBean
The
DynaBean that this ActionForm is backed by. |
protected static org.apache.commons.logging.Log |
logger
Commons Logging
|
protected boolean |
pathValidation
Indicates whether the ActionMapping's path should be used for the
validation key.
|
page, validatorResults
multipartRequestHandler, servlet
Constructor and Description |
---|
BeanValidatorForm(Object bean)
Construct a new
BeanValidatorForm with the specified
bean. |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(String name,
String key)
Does the specified mapped property contain a value for the specified
key value?
|
Object |
get(String name)
Return the value of a simple property with the specified name.
|
Object |
get(String name,
int index)
Return the value of an indexed property with the specified name.
|
Object |
get(String name,
String key)
Return the value of a mapped property with the specified name, or
null if there is no value for the specified key. |
org.apache.commons.beanutils.DynaBean |
getDynaBean()
Return the
DynaBean that this ActionForm
is backed by. |
org.apache.commons.beanutils.DynaClass |
getDynaClass()
Return the
DynaClass instance that describes the set of
properties available for this DynaBean. |
Object |
getInstance()
Return the
Bean that this ActionForm is
backed by. |
String |
getStrutsConfigFormName()
Return name used to identify the ActionForm in the
struts-config.xml.
|
String |
getValidationKey(ActionMapping mapping,
javax.servlet.http.HttpServletRequest request)
Returns the Validation key
|
void |
initialize(FormBeanConfig formBeanConfig)
Perform intialization of the ActionForm.
|
protected boolean |
isPathValidation()
Indicates whether this form should validate based on the
ActionMapping 's path. |
void |
remove(String name,
String key)
Remove any existing value for the specified key on the specified mapped
property.
|
void |
set(String name,
int index,
Object value)
Set the value of an indexed property with the specified name.
|
void |
set(String name,
Object value)
Set the value of a simple property with the specified name.
|
void |
set(String name,
String key,
Object value)
Set the value of a mapped property with the specified name.
|
protected void |
setPathValidation(boolean pathValidation)
Set whether this form should validate based on the
ActionMapping 's path. |
int |
size(String name)
Return the size of an indexed or mapped property.
|
determinePage, getPage, getResultValueMap, getValidatorResults, reset, setPage, setValidatorResults, validate
getMultipartRequestHandler, getServlet, getServletWrapper, reset, setMultipartRequestHandler, setServlet, validate
protected static org.apache.commons.logging.Log logger
protected org.apache.commons.beanutils.DynaBean dynaBean
DynaBean
that this ActionForm is backed by.protected boolean pathValidation
public BeanValidatorForm(Object bean)
BeanValidatorForm
with the specified
bean.protected void setPathValidation(boolean pathValidation)
Set whether this form should validate based on the
ActionMapping
's path.
protected boolean isPathValidation()
Indicates whether this form should validate based on the
ActionMapping
's path.
public void initialize(FormBeanConfig formBeanConfig)
Perform intialization of the ActionForm.
This method is called when the form is created.
public String getStrutsConfigFormName()
public org.apache.commons.beanutils.DynaBean getDynaBean()
Return the DynaBean
that this ActionForm
is backed by.
public Object getInstance()
Return the Bean
that this ActionForm
is
backed by.
If the DynaBean
is a WrapDynaBean
type
then this method returns the 'Wrapped' POJO bean associated with it. If
you require the actual WrapDynaBean
then use the
getDynaBean()
method.
public int size(String name)
Return the size of an indexed or mapped property.
public String getValidationKey(ActionMapping mapping, javax.servlet.http.HttpServletRequest request)
getValidationKey
in class ValidatorForm
mapping
- The mapping used to select this instancerequest
- The servlet request we are processingpublic org.apache.commons.beanutils.DynaClass getDynaClass()
DynaClass
instance that describes the set of
properties available for this DynaBean.getDynaClass
in interface org.apache.commons.beanutils.DynaBean
public Object get(String name)
get
in interface org.apache.commons.beanutils.DynaBean
name
- Name of the property whose value is to be retrievedpublic Object get(String name, int index)
get
in interface org.apache.commons.beanutils.DynaBean
name
- Name of the property whose value is to be retrievedindex
- Index of the value to be retrievedpublic Object get(String name, String key)
null
if there is no value for the specified key.get
in interface org.apache.commons.beanutils.DynaBean
name
- Name of the property whose value is to be retrievedkey
- Key of the value to be retrievedpublic void set(String name, Object value)
set
in interface org.apache.commons.beanutils.DynaBean
name
- Name of the property whose value is to be setvalue
- Value to which this property is to be setpublic void set(String name, int index, Object value)
set
in interface org.apache.commons.beanutils.DynaBean
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 setpublic void set(String name, String key, Object value)
set
in interface org.apache.commons.beanutils.DynaBean
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 setpublic boolean contains(String name, String key)
contains
in interface org.apache.commons.beanutils.DynaBean
name
- Name of the property to checkkey
- Name of the key to checkpublic void remove(String name, String key)
remove
in interface org.apache.commons.beanutils.DynaBean
name
- Name of the property for which a value is to be removedkey
- Key of the value to be removedCopyright © 2000–2016 Apache Software Foundation. All rights reserved.