public class DynaActionForm extends ActionForm implements org.apache.commons.beanutils.DynaBean
Specialized subclass of ActionForm that allows the creation
of form beans with dynamic sets of properties, without requiring the
developer to create a Java class for each type of form bean.
USAGE NOTE - Since Struts 1.1, the reset
method no longer initializes property values to those specified in
<form-property> elements in the Struts module
configuration file. If you wish to utilize that behavior, the simplest
solution is to subclass DynaActionForm and call the
initialize method inside it.
| Modifier and Type | Field and Description |
|---|---|
protected DynaActionFormClass |
dynaClass
The
DynaActionFormClass with which we are associated. |
protected HashMap |
dynaValues
The set of property values for this
DynaActionForm,
keyed by property name. |
multipartRequestHandler, servlet| Constructor and Description |
|---|
DynaActionForm() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(String name,
String key)
Indicates if 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.DynaClass |
getDynaClass()
Return the
DynaClass instance that describes the set of
properties available for this DynaBean. |
protected org.apache.commons.beanutils.DynaProperty |
getDynaProperty(String name)
Return the property descriptor for the specified property name.
|
Map |
getMap()
Returns the
Map containing the property values. |
String |
getString(String name)
Return the value of a
String property with the
specified name. |
String[] |
getStrings(String name)
Return the value of a
String[] property with the
specified name. |
void |
initialize(ActionMapping mapping)
Initialize all bean properties to their initial values, as specified
in the
FormPropertyConfig elements associated with the
definition of this DynaActionForm. |
void |
initialize(FormBeanConfig config)
Initialize the specified form bean.
|
protected boolean |
isDynaAssignable(Class dest,
Class source)
Indicates if an object of the source class is assignable to the
destination class.
|
void |
remove(String name,
String key)
Remove any existing value for the specified key on the specified
mapped property.
|
void |
reset(ActionMapping mapping,
javax.servlet.http.HttpServletRequest request)
Reset the properties to their
initial value if their
reset configuration is set to true or if
reset is set to a list of HTTP request methods that
includes the method of given request object. |
void |
reset(ActionMapping mapping,
javax.servlet.ServletRequest request)
Reset bean properties to their default state, as needed.
|
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.
|
String |
toString()
Render a String representation of this object.
|
getMultipartRequestHandler, getServlet, getServletWrapper, setMultipartRequestHandler, setServlet, validate, validateprotected DynaActionFormClass dynaClass
The DynaActionFormClass with which we are associated.
protected HashMap dynaValues
The set of property values for this DynaActionForm,
keyed by property name.
public void initialize(ActionMapping mapping)
Initialize all bean properties to their initial values, as specified
in the FormPropertyConfig elements associated with the
definition of this DynaActionForm.
mapping - The mapping used to select this instancepublic void initialize(FormBeanConfig config)
Initialize the specified form bean.
config - The configuration for the form bean to initialize.public void reset(ActionMapping mapping, javax.servlet.ServletRequest request)
Reset bean properties to their default state, as needed. This method is called before the properties are repopulated by the controller.
The default implementation attempts to forward to the HTTP version of this method.
reset in class ActionFormmapping - The mapping used to select this instancerequest - The servlet request we are processingpublic void reset(ActionMapping mapping, javax.servlet.http.HttpServletRequest request)
Reset the properties to their initial value if their
reset configuration is set to true or if
reset is set to a list of HTTP request methods that
includes the method of given request object.
reset in class ActionFormmapping - The mapping used to select this instancerequest - The servlet request we are processingpublic boolean contains(String name, String key)
Indicates if the specified mapped property contain a value for the specified key value.
contains in interface org.apache.commons.beanutils.DynaBeanname - Name of the property to checkkey - Name of the key to checktrue if the specified mapped property contains a
value for the specified key value; true
otherwise.NullPointerException - if there is no property of the
specified nameIllegalArgumentException - if there is no mapped property of the
specified namepublic Object get(String name)
Return the value of a simple property with the specified name.
get in interface org.apache.commons.beanutils.DynaBeanname - Name of the property whose value is to be retrievedIllegalArgumentException - if there is no property of the
specified nameNullPointerException - if the type specified for the property
is invalidpublic Object get(String name, int index)
Return the value of an indexed property with the specified name.
get in interface org.apache.commons.beanutils.DynaBeanname - Name of the property whose value is to be retrievedindex - Index of the value to be retrievedIllegalArgumentException - if there is no property of the
specified nameIllegalArgumentException - if the specified property exists, but
is not indexedNullPointerException - if no array or List has been
initialized for this propertypublic 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.
get in interface org.apache.commons.beanutils.DynaBeanname - Name of the property whose value is to be retrievedkey - Key of the value to be retrievednull if there is no value for the specified key.NullPointerException - if there is no property of the
specified nameIllegalArgumentException - if the specified property exists, but
is not mappedpublic String getString(String name)
Return the value of a String property with the
specified name. This is equivalent to calling (String)
dynaForm.get(name).
name - Name of the property whose value is to be retrieved.String property with the specified
name.IllegalArgumentException - if there is no property of the
specified nameNullPointerException - if the type specified for the property
is invalidClassCastException - if the property is not a String.public String[] getStrings(String name)
Return the value of a String[] property with the
specified name. This is equivalent to calling (String[])
dynaForm.get(name).
name - Name of the property whose value is to be retrieved.String[] property with the
specified name.IllegalArgumentException - if there is no property of the
specified nameNullPointerException - if the type specified for the property
is invalidClassCastException - if the property is not a String[].public org.apache.commons.beanutils.DynaClass getDynaClass()
Return the DynaClass instance that describes the set of
properties available for this DynaBean.
getDynaClass in interface org.apache.commons.beanutils.DynaBeanDynaClass instance that describes the set of
properties available for this DynaBean.public Map getMap()
Returns the Map containing the property values. This is
done mostly to facilitate accessing the DynaActionForm
through JavaBeans accessors, in order to use the JavaServer Pages
Standard Tag Library (JSTL).
For instance, the normal JSTL EL syntax for accessing an
ActionForm would be something like this:
${formbean.prop}
The JSTL EL syntax for accessing a DynaActionForm looks
something like this (because of the presence of this
getMap() method):
${dynabean.map.prop}
Map containing the property values.public void remove(String name, String key)
Remove any existing value for the specified key on the specified mapped property.
remove in interface org.apache.commons.beanutils.DynaBeanname - Name of the property for which a value is to be removedkey - Key of the value to be removedNullPointerException - if there is no property of the
specified nameIllegalArgumentException - if there is no mapped property of the
specified namepublic void set(String name, Object value)
Set the value of a simple property with the specified name.
set in interface org.apache.commons.beanutils.DynaBeanname - Name of the property whose value is to be setvalue - Value to which this property is to be setorg.apache.commons.beanutils.ConversionException - if the specified value cannot be
converted to the type required for
this propertyIllegalArgumentException - if there is no property of the
specified nameNullPointerException - if the type specified for the property
is invalidNullPointerException - if an attempt is made to set a
primitive property to nullpublic void set(String name, int index, Object value)
Set the value of an indexed property with the specified name.
set in interface org.apache.commons.beanutils.DynaBeanname - 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 setorg.apache.commons.beanutils.ConversionException - if the specified value cannot be
converted to the type required for
this propertyNullPointerException - if there is no property of the
specified nameIllegalArgumentException - if the specified property exists, but
is not indexedIndexOutOfBoundsException - if the specified index is outside the
range of the underlying propertypublic void set(String name, String key, Object value)
Set the value of a mapped property with the specified name.
set in interface org.apache.commons.beanutils.DynaBeanname - 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 setNullPointerException - if there is no property of the
specified nameIllegalArgumentException - if the specified property exists, but
is not mappedpublic String toString()
Render a String representation of this object.
protected org.apache.commons.beanutils.DynaProperty getDynaProperty(String name)
Return the property descriptor for the specified property name.
name - Name of the property for which to retrieve the descriptorIllegalArgumentException - if this is not a valid property name
for our DynaClassCopyright © 2000-2017 Apache Software Foundation. All Rights Reserved.