Class DynaActionForm
- All Implemented Interfaces:
Serializable,DynaBean
- Direct Known Subclasses:
DynaValidatorForm
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.
- Since:
- Struts 1.1
- Version:
- $Rev$ $Date: 2005-11-12 11:52:08 -0500 (Sat, 12 Nov 2005) $
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DynaActionFormClassTheDynaActionFormClasswith which we are associated.The set of property values for thisDynaActionForm, keyed by property name.Fields inherited from class org.apache.struts.action.ActionForm
multipartRequestHandler, servlet -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates if 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, ornullif there is no value for the specified key.Return theDynaClassinstance that describes the set of properties available for thisDynaBean.protected DynaPropertygetDynaProperty(String name) Return the property descriptor for the specified property name.getMap()Returns theMapcontaining the property values.Return the value of aStringproperty with the specified name.String[]getStrings(String name) Return the value of aString[]property with the specified name.voidinitialize(ActionMapping mapping) Initialize all bean properties to their initial values, as specified in theFormPropertyConfigelements associated with the definition of thisDynaActionForm.voidinitialize(FormBeanConfig config) Initialize the specified form bean.protected booleanisDynaAssignable(Class<?> dest, Class<?> source) Indicates if an object of the source class is assignable to the destination class.voidRemove any existing value for the specified key on the specified mapped property.voidreset(ActionMapping mapping, HttpServletRequest request) Reset the properties to theirinitialvalue if theirresetconfiguration is set to true or ifresetis set to a list of HTTP request methods that includes the method of givenrequestobject.voidreset(ActionMapping mapping, ServletRequest request) Reset bean properties to their default state, as needed.voidSet the value of an indexed property with the specified name.voidSet the value of a simple property with the specified name.voidSet the value of a mapped property with the specified name.toString()Render a String representation of this object.Methods inherited from class org.apache.struts.action.ActionForm
getMultipartRequestHandler, getServlet, getServletWrapper, setMultipartRequestHandler, setServlet, validate, validate
-
Field Details
-
dynaClass
The
DynaActionFormClasswith which we are associated. -
dynaValues
The set of property values for this
DynaActionForm, keyed by property name.
-
-
Constructor Details
-
DynaActionForm
public DynaActionForm()
-
-
Method Details
-
initialize
Initialize all bean properties to their initial values, as specified in the
FormPropertyConfigelements associated with the definition of thisDynaActionForm.- Parameters:
mapping- The mapping used to select this instance
-
initialize
Initialize the specified form bean.
- Parameters:
config- The configuration for the form bean to initialize.
-
reset
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.
- Overrides:
resetin classActionForm- Parameters:
mapping- The mapping used to select this instancerequest- The servlet request we are processing
-
reset
Reset the properties to their
initialvalue if theirresetconfiguration is set to true or ifresetis set to a list of HTTP request methods that includes the method of givenrequestobject.- Overrides:
resetin classActionForm- Parameters:
mapping- The mapping used to select this instancerequest- The servlet request we are processing
-
contains
Indicates if the specified mapped property contain a value for the specified key value.
- Specified by:
containsin interfaceDynaBean- Parameters:
name- Name of the property to checkkey- Name of the key to check- Returns:
trueif the specified mapped property contains a value for the specified key value;trueotherwise.- Throws:
NullPointerException- if there is no property of the specified nameIllegalArgumentException- if there is no mapped property of the specified name
-
get
Return the value of a simple property with the specified name.
- Specified by:
getin interfaceDynaBean- Parameters:
name- Name of the property whose value is to be retrieved- Returns:
- The value of a simple property with the specified name.
- Throws:
IllegalArgumentException- if there is no property of the specified nameNullPointerException- if the type specified for the property is invalid
-
get
Return the value of an indexed property with the specified name.
- Specified by:
getin interfaceDynaBean- Parameters:
name- Name of the property whose value is to be retrievedindex- Index of the value to be retrieved- Returns:
- The value of an indexed property with the specified name.
- Throws:
IllegalArgumentException- 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 property
-
get
Return the value of a mapped property with the specified name, or
nullif there is no value for the specified key.- Specified by:
getin interfaceDynaBean- Parameters:
name- Name of the property whose value is to be retrievedkey- Key of the value to be retrieved- Returns:
- The value of a mapped property with the specified name, or
nullif there is no value for the specified key. - Throws:
NullPointerException- if there is no property of the specified nameIllegalArgumentException- if the specified property exists, but is not mapped
-
getString
Return the value of a
Stringproperty with the specified name. This is equivalent to calling(String) dynaForm.get(name).- Parameters:
name- Name of the property whose value is to be retrieved.- Returns:
- The value of a
Stringproperty with the specified name. - Throws:
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.- Since:
- Struts 1.2
-
getStrings
Return the value of a
String[]property with the specified name. This is equivalent to calling(String[]) dynaForm.get(name).- Parameters:
name- Name of the property whose value is to be retrieved.- Returns:
- The value of a
String[]property with the specified name. - Throws:
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[].- Since:
- Struts 1.2
-
getDynaClass
Return the
DynaClassinstance that describes the set of properties available for thisDynaBean.- Specified by:
getDynaClassin interfaceDynaBean- Returns:
- The
DynaClassinstance that describes the set of properties available for thisDynaBean.
-
getMap
Returns the
Mapcontaining the property values. This is done mostly to facilitate accessing theDynaActionFormthrough JavaBeans accessors, in order to use the JavaServer Pages Standard Tag Library (JSTL).For instance, the normal JSTL EL syntax for accessing an
ActionFormwould be something like this:${formbean.prop}The JSTL EL syntax for accessing aDynaActionFormlooks something like this (because of the presence of thisgetMap()method):${dynabean.map.prop}- Returns:
- The
Mapcontaining the property values.
-
remove
Remove any existing value for the specified key on the specified mapped property.
- Specified by:
removein interfaceDynaBean- Parameters:
name- Name of the property for which a value is to be removedkey- Key of the value to be removed- Throws:
NullPointerException- if there is no property of the specified nameIllegalArgumentException- if there is no mapped property of the specified name
-
set
Set the value of a simple property with the specified name.
- Specified by:
setin interfaceDynaBean- Parameters:
name- Name of the property whose value is to be setvalue- Value to which this property is to be set- Throws:
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 null
-
set
Set the value of an indexed property with the specified name.
- Specified by:
setin interfaceDynaBean- 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- Throws:
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 property
-
set
Set the value of a mapped property with the specified name.
- Specified by:
setin interfaceDynaBean- 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- Throws:
NullPointerException- if there is no property of the specified nameIllegalArgumentException- if the specified property exists, but is not mapped
-
toString
Render a String representation of this object.
-
getDynaProperty
Return the property descriptor for the specified property name.
- Parameters:
name- Name of the property for which to retrieve the descriptor- Returns:
- The property descriptor for the specified property name.
- Throws:
IllegalArgumentException- if this is not a valid property name for our DynaClass
-
isDynaAssignable
Indicates if an object of the source class is assignable to the destination class.
- Parameters:
dest- Destination classsource- Source class- Returns:
trueif the source is assignable to the destination;falseotherwise.
-