org.apache.struts.action
Class DynaActionForm
- DynaBean, Serializable
public class DynaActionForm
implements 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.
Version:
- Craig R. McClanahan
- Struts 1.1
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.
|
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, String key) - Return the value of a mapped property with the specified name,
or
null if there is no value for the specified key.
|
Object | get(String name, int index) - Return the value of an indexed property with the specified name.
|
DynaClass | getDynaClass() - Return the
DynaClass instance that describes the set of
properties available for this DynaBean.
|
protected DynaProperty | getDynaProperty(String name) - Return the property descriptor for the specified property name.
|
Map | getMap() - Returns the
Map containing the property values.
|
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 .
|
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, HttpServletRequest request) - Reset all bean properties to their default state.
|
void | reset(ActionMapping mapping, ServletRequest request) - Reset all bean properties to their default state.
|
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.
|
void | set(String name, int index, Object value) - Set the value of an indexed property with the specified name.
|
(package private) void | setDynaActionFormClass(DynaActionFormClass dynaClass) - Set the DynaActionFormClass instance that we are associated with.
|
String | toString() - Render a String representation of this object.
|
dynaClass
protected DynaActionFormClass dynaClass
The DynaActionFormClass with which we are associated.
dynaValues
protected HashMap dynaValues
The set of property values for this DynaActionForm, keyed by
property name.
contains
public boolean contains(String name,
String key)
Indicates if the specified mapped property contain a value for the specified
key value.
name
- Name of the property to checkkey
- Name of the key to check
get
public Object get(String name)
Return the value of a simple property with the specified name.
name
- Name of the property whose value is to be retrieved
get
public 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.
name
- Name of the property whose value is to be retrievedkey
- Key of the value to be retrieved
get
public Object get(String name,
int index)
Return the value of an indexed property with the specified name.
name
- Name of the property whose value is to be retrievedindex
- Index of the value to be retrieved
getDynaClass
public DynaClass getDynaClass()
Return the DynaClass
instance that describes the set of
properties available for this DynaBean.
getDynaProperty
protected DynaProperty getDynaProperty(String name)
Return the property descriptor for the specified property name.
name
- Name of the property for which to retrieve the descriptor
getMap
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.
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}
initialize
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 instance
- Struts 1.1
isDynaAssignable
protected boolean isDynaAssignable(Class dest,
Class source)
Indicates if an object of the source class is assignable to the destination class.
dest
- Destination classsource
- Source class
remove
public void remove(String name,
String key)
Remove any existing value for the specified key on the
specified mapped property.
name
- Name of the property for which a value is to
be removedkey
- Key of the value to be removed
reset
public void reset(ActionMapping mapping,
HttpServletRequest request)
Reset all bean properties to their default state. This method is
called before the properties are repopulated by the controller servlet.
The default implementation (since Struts 1.1) does nothing.
Subclasses may override this method to reset bean properties to
default values, or the
initialize()
method may be used to
initialize property values to those provided in the form property
configuration information (which was the previous behavior of
this method).
- reset in interface ActionForm
mapping
- The mapping used to select this instancerequest
- The servlet request we are processing
reset
public void reset(ActionMapping mapping,
ServletRequest request)
Reset all bean properties to their default state. This method is
called before the properties are repopulated by the controller
servlet.
The default implementation attempts to forward to the HTTP
version of this method.
- reset in interface ActionForm
mapping
- The mapping used to select this instancerequest
- The servlet request we are processing
set
public void set(String name,
Object value)
Set the value of a simple property with the specified name.
name
- Name of the property whose value is to be setvalue
- Value to which this property is to be set
set
public void set(String name,
String key,
Object value)
Set the value of a mapped property with the specified name.
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
set
public void set(String name,
int index,
Object value)
Set the value of an indexed property with the specified name.
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
setDynaActionFormClass
(package private) void setDynaActionFormClass(DynaActionFormClass dynaClass)
Set the DynaActionFormClass instance that we are associated with.
dynaClass
- The DynaActionFormClass instance for this bean
toString
public String toString()
Render a String representation of this object.
Copyright B) 2000-2005 - Apache Software Foundation