Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.struts.action
Class DynaActionForm  view DynaActionForm download DynaActionForm.java

java.lang.Object
  extended byorg.apache.struts.action.ActionForm
      extended byorg.apache.struts.action.DynaActionForm
All Implemented Interfaces:
org.apache.commons.beanutils.DynaBean, java.io.Serializable

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.

Since:
Struts 1.1
Version:
$Rev: 168012 $ $Date: 2005-05-03 23:39:10 +0100 (Tue, 03 May 2005) $

Field Summary
protected  DynaActionFormClass dynaClass
          The DynaActionFormClass with which we are associated.
protected  java.util.HashMap dynaValues
          The set of property values for this DynaActionForm, keyed by property name.
 
Fields inherited from class org.apache.struts.action.ActionForm
multipartRequestHandler, servlet
 
Constructor Summary
DynaActionForm()
           
 
Method Summary
 boolean contains(java.lang.String name, java.lang.String key)
          Indicates if the specified mapped property contain a value for the specified key value.
 java.lang.Object get(java.lang.String name)
          Return the value of a simple property with the specified name.
 java.lang.Object get(java.lang.String name, int index)
          Return the value of an indexed property with the specified name.
 java.lang.Object get(java.lang.String name, java.lang.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(java.lang.String name)
          Return the property descriptor for the specified property name.
 java.util.Map getMap()
          Returns the Map containing the property values.
 java.lang.String getString(java.lang.String name)
          Return the value of a String property with the specified name.
 java.lang.String[] getStrings(java.lang.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 org.apache.struts.config.FormPropertyConfig elements associated with the definition of this DynaActionForm.
 void initialize(org.apache.struts.config.FormBeanConfig config)
           
protected  boolean isDynaAssignable(java.lang.Class dest, java.lang.Class source)
          Indicates if an object of the source class is assignable to the destination class.
 void remove(java.lang.String name, java.lang.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 bean properties to their default state, as needed.
 void reset(ActionMapping mapping, javax.servlet.ServletRequest request)
          Reset bean properties to their default state, as needed.
 void set(java.lang.String name, int index, java.lang.Object value)
          Set the value of an indexed property with the specified name.
 void set(java.lang.String name, java.lang.Object value)
          Set the value of a simple property with the specified name.
 void set(java.lang.String name, java.lang.String key, java.lang.Object value)
          Set the value of a mapped property with the specified name.
(package private)  void setDynaActionFormClass(DynaActionFormClass dynaClass)
          Set the DynaActionFormClass instance with which we are associated.
 java.lang.String toString()
          Render a String representation of this object.
 
Methods inherited from class org.apache.struts.action.ActionForm
getMultipartRequestHandler, getServlet, getServletWrapper, setMultipartRequestHandler, setServlet, validate, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dynaClass

protected DynaActionFormClass dynaClass

The DynaActionFormClass with which we are associated.


dynaValues

protected java.util.HashMap dynaValues

The set of property values for this DynaActionForm, keyed by property name.

Constructor Detail

DynaActionForm

public DynaActionForm()
Method Detail

initialize

public void initialize(ActionMapping mapping)

Initialize all bean properties to their initial values, as specified in the org.apache.struts.config.FormPropertyConfig elements associated with the definition of this DynaActionForm.


initialize

public void initialize(org.apache.struts.config.FormBeanConfig config)

reset

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.

Overrides:
reset in class ActionForm

reset

public void reset(ActionMapping mapping,
                  javax.servlet.http.HttpServletRequest 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 (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 behavior of this method in some release candidates).

Overrides:
reset in class ActionForm

contains

public boolean contains(java.lang.String name,
                        java.lang.String key)

Indicates if the specified mapped property contain a value for the specified key value.

Specified by:
contains in interface org.apache.commons.beanutils.DynaBean

get

public java.lang.Object get(java.lang.String name)

Return the value of a simple property with the specified name.

Specified by:
get in interface org.apache.commons.beanutils.DynaBean

get

public java.lang.Object get(java.lang.String name,
                            int index)

Return the value of an indexed property with the specified name.

Specified by:
get in interface org.apache.commons.beanutils.DynaBean

get

public java.lang.Object get(java.lang.String name,
                            java.lang.String key)

Return the value of a mapped property with the specified name, or null if there is no value for the specified key.

Specified by:
get in interface org.apache.commons.beanutils.DynaBean

getString

public java.lang.String getString(java.lang.String name)

Return the value of a String property with the specified name. This is equivalent to calling (String) dynaForm.get(name).

Since:
Struts 1.2

getStrings

public java.lang.String[] getStrings(java.lang.String name)

Return the value of a String[] property with the specified name. This is equivalent to calling (String[]) dynaForm.get(name).

Since:
Struts 1.2

getDynaClass

public org.apache.commons.beanutils.DynaClass getDynaClass()

Return the DynaClass instance that describes the set of properties available for this DynaBean.

Specified by:
getDynaClass in interface org.apache.commons.beanutils.DynaBean

getMap

public java.util.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}


remove

public void remove(java.lang.String name,
                   java.lang.String key)

Remove any existing value for the specified key on the specified mapped property.

Specified by:
remove in interface org.apache.commons.beanutils.DynaBean

set

public void set(java.lang.String name,
                java.lang.Object value)

Set the value of a simple property with the specified name.

Specified by:
set in interface org.apache.commons.beanutils.DynaBean

set

public void set(java.lang.String name,
                int index,
                java.lang.Object value)

Set the value of an indexed property with the specified name.

Specified by:
set in interface org.apache.commons.beanutils.DynaBean

set

public void set(java.lang.String name,
                java.lang.String key,
                java.lang.Object value)

Set the value of a mapped property with the specified name.

Specified by:
set in interface org.apache.commons.beanutils.DynaBean

toString

public java.lang.String toString()

Render a String representation of this object.


setDynaActionFormClass

void setDynaActionFormClass(DynaActionFormClass dynaClass)

Set the DynaActionFormClass instance with which we are associated.


getDynaProperty

protected org.apache.commons.beanutils.DynaProperty getDynaProperty(java.lang.String name)

Return the property descriptor for the specified property name.


isDynaAssignable

protected boolean isDynaAssignable(java.lang.Class dest,
                                   java.lang.Class source)

Indicates if an object of the source class is assignable to the destination class.