Class FormBeanConfig
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ActionFormBean
A JavaBean representing the configuration information of a
<form-bean>
element in a Struts configuration file.
- Since:
- Struts 1.1
- Version:
- $Rev$ $Date: 2006-01-17 07:26:20 -0500 (Tue, 17 Jan 2006) $
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected DynaActionFormClass
The DynaActionFormClass associated with a DynaActionForm.protected boolean
Is the form bean class an instance of DynaActionForm with dynamic properties?protected boolean
Have the inheritance values for this class been applied?protected HashMap
<String, FormPropertyConfig> The set of FormProperty elements defining dynamic form properties for this form bean, keyed by property name.protected String
The name of the FormBeanConfig that this config inherits configuration information from.protected String
The lockable object we can synchronize on when creating DynaActionFormClass.protected String
The unique identifier of this form bean, which is used to reference this bean inActionMapping
instances as well as for the name of the request or session attribute under which the corresponding form bean instance is created or accessed.protected boolean
Is this DynaClass currently restricted (for DynaBeans with a MutableDynaClass).protected String
The fully qualified Java class name of the implementation class to be used or generated.Fields inherited from class org.apache.struts.config.BaseConfig
configured
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a newFormPropertyConfig
instance to the set associated with this module.boolean
canReuse
(ActionForm form) Checks if the givenActionForm
instance is suitable for use as an alternative to calling thisFormBeanConfig
instance'screateActionForm
method.protected boolean
checkCircularInheritance
(ModuleConfig moduleConfig) Traces the hierarchy of this object to check if any of the ancestors is extending this instance.createActionForm
(ActionServlet servlet) Create and return anActionForm
instance appropriate to the information in thisFormBeanConfig
.createActionForm
(ActionContext context) Create and return anActionForm
instance appropriate to the information in thisFormBeanConfig
.findFormPropertyConfig
(String name) Return the form property configuration for the specified property name, if any; otherwise returnnull
.Return the form property configurations for this module.protected Class
<?> Return theClass
instance for the form bean implementation configured by thisFormBeanConfig
instance.void
freeze()
Freeze the configuration of this component.Return the DynaActionFormClass associated with a DynaActionForm.boolean
getName()
getType()
protected void
inheritFormProperties
(FormBeanConfig config) Compare the form properties of this bean with that of the given and copy those that are not present.void
inheritFrom
(FormBeanConfig config) Inherit values that have not been overridden from the provided config object.boolean
boolean
Indicates whether a MutableDynaClass is currently restricted.void
processExtends
(ModuleConfig moduleConfig) Inherit configuration information from the FormBeanConfig that this instance is extending.void
Remove the specified form property configuration instance.void
setExtends
(String extend) void
void
setRestricted
(boolean restricted) Set whether a MutableDynaClass is currently restricted.void
toString()
Return a String representation of this object.Methods inherited from class org.apache.struts.config.BaseConfig
copyProperties, getProperties, getProperty, inheritProperties, setProperties, setProperty, throwIfConfigured
-
Field Details
-
formProperties
The set of FormProperty elements defining dynamic form properties for this form bean, keyed by property name. -
lock
The lockable object we can synchronize on when creating DynaActionFormClass.
-
dynaActionFormClass
The DynaActionFormClass associated with a DynaActionForm. -
dynamic
protected boolean dynamicIs the form bean class an instance of DynaActionForm with dynamic properties? -
inherit
The name of the FormBeanConfig that this config inherits configuration information from. -
extensionProcessed
protected boolean extensionProcessedHave the inheritance values for this class been applied? -
name
The unique identifier of this form bean, which is used to reference this bean inActionMapping
instances as well as for the name of the request or session attribute under which the corresponding form bean instance is created or accessed. -
type
The fully qualified Java class name of the implementation class to be used or generated. -
restricted
protected boolean restrictedIs this DynaClass currently restricted (for DynaBeans with a MutableDynaClass).
-
-
Constructor Details
-
FormBeanConfig
public FormBeanConfig()
-
-
Method Details
-
getDynaActionFormClass
Return the DynaActionFormClass associated with a DynaActionForm.
- Throws:
IllegalArgumentException
- if the ActionForm is not dynamic
-
getDynamic
public boolean getDynamic() -
getExtends
-
setExtends
-
isExtensionProcessed
public boolean isExtensionProcessed() -
getName
-
setName
-
getType
-
setType
-
isRestricted
public boolean isRestricted()Indicates whether a MutableDynaClass is currently restricted.
If so, no changes to the existing registration of property names, data types, readability, or writeability are allowed.
-
setRestricted
public void setRestricted(boolean restricted) Set whether a MutableDynaClass is currently restricted.
If so, no changes to the existing registration of property names, data types, readability, or writeability are allowed.
-
checkCircularInheritance
Traces the hierarchy of this object to check if any of the ancestors is extending this instance.
- Parameters:
moduleConfig
- The configuration for the module being configured.- Returns:
- true if circular inheritance was detected.
-
inheritFormProperties
protected void inheritFormProperties(FormBeanConfig config) throws ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException Compare the form properties of this bean with that of the given and copy those that are not present.
- Parameters:
config
- The form bean config to copy properties from.- Throws:
ClassNotFoundException
IllegalAccessException
InstantiationException
InvocationTargetException
- See Also:
-
createActionForm
public ActionForm createActionForm(ActionServlet servlet) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException Create and return anActionForm
instance appropriate to the information in thisFormBeanConfig
.Although this method is not formally deprecated yet, where possible, the form which accepts an
ActionContext
as an argument is preferred, to help sever direct dependencies on the Servlet API. As the ActionContext becomes more familiar in Struts, this method will almost certainly be deprecated.- Parameters:
servlet
- The action servlet- Returns:
- ActionForm instance
- Throws:
InstantiationException
- if this Class represents an abstract class, an array class, a primitive type, or void; or if instantiation fails for some other reasonIllegalAccessException
- if the Class or the appropriate constructor is not accessibleIllegalArgumentException
- if the number of actual and formal parameters differInvocationTargetException
- if the underlying constructor throws an exceptionNoSuchMethodException
- if a matching method is not foundSecurityException
- if there is a security-exceptionClassNotFoundException
- if the specified class cannot be loaded
-
createActionForm
public ActionForm createActionForm(ActionContext context) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException Create and return anActionForm
instance appropriate to the information in thisFormBeanConfig
.NOTE: If the given
ActionContext
is not of typeServletActionContext
(or a subclass), then the form which is returned will have a nullservlet
property. Some of the subclasses ofActionForm
included in Struts will later throw aNullPointerException
in this case.TODO: Find a way to control this direct dependency on the Servlet API.
- Parameters:
context
- The ActionContext.- Returns:
- ActionForm instance
- Throws:
InstantiationException
- if this Class represents an abstract class, an array class, a primitive type, or void; or if instantiation fails for some other reasonIllegalAccessException
- if the Class or the appropriate constructor is not accessibleIllegalArgumentException
- if the number of actual and formal parameters differInvocationTargetException
- if the underlying constructor throws an exceptionNoSuchMethodException
- if a matching method is not foundSecurityException
- if there is a security-exceptionClassNotFoundException
- if the specified class cannot be loaded
-
canReuse
Checks if the given
ActionForm
instance is suitable for use as an alternative to calling thisFormBeanConfig
instance'screateActionForm
method.- Parameters:
form
- an existing form instance that may be reused.- Returns:
- true if the given form can be reused as the form for this config.
-
addFormPropertyConfig
Add a newFormPropertyConfig
instance to the set associated with this module.- Parameters:
config
- The new configuration instance to be added- Throws:
IllegalArgumentException
- if this property name has already been defined
-
findFormPropertyConfig
Return the form property configuration for the specified property name, if any; otherwise returnnull
.- Parameters:
name
- Form property name to find a configuration for
-
findFormPropertyConfigs
Return the form property configurations for this module. If there are none, a zero-length array is returned. -
freeze
public void freeze()Freeze the configuration of this component.- Overrides:
freeze
in classBaseConfig
-
inheritFrom
public void inheritFrom(FormBeanConfig config) throws ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException Inherit values that have not been overridden from the provided config object. Subclasses overriding this method should verify that the given parameter is of a class that contains a property it is trying to inherit:
if (config instanceof MyCustomConfig) { MyCustomConfig myConfig = (MyCustomConfig) config; if (getMyCustomProp() == null) { setMyCustomProp(myConfig.getMyCustomProp()); } }
If the given
config
is extending another object, those extensions should be resolved before it's used as a parameter to this method.- Parameters:
config
- The object that this instance will be inheriting its values from.- Throws:
ClassNotFoundException
IllegalAccessException
InstantiationException
InvocationTargetException
- See Also:
-
processExtends
public void processExtends(ModuleConfig moduleConfig) throws ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException Inherit configuration information from the FormBeanConfig that this instance is extending. This method verifies that any form bean config object that it inherits from has also had its processExtends() method called.
- Parameters:
moduleConfig
- TheModuleConfig
that this bean is from.- Throws:
ClassNotFoundException
IllegalAccessException
InstantiationException
InvocationTargetException
- See Also:
-
removeFormPropertyConfig
Remove the specified form property configuration instance.- Parameters:
config
- FormPropertyConfig instance to be removed
-
toString
Return a String representation of this object. -
formBeanClass
Return theClass
instance for the form bean implementation configured by thisFormBeanConfig
instance. This method uses the same algorithm asRequestUtils.applicationClass()
but is reproduced to avoid a runtime dependence.
-