DynaAction Form

Struts 1.2 mandated that every HTML form in the JSPs have an associated ActionForm. Struts 1.1 changed all that with the introduction of
DynaActionForm – dynamic ActionForm as the name suggests. DynaActionForm is defined in the struts-config.xml as a form-bean. A sample
DynaActionForm is shown below Sample DynaActionForm

There are two things

  1. For a DynaActionForm, the type attribute of the form-bean is always org.apache.struts.action.DynaActionForm.
  2. A regular ActionForm is developed in Java and declared in the struts-config.xml. The JavaBeans properties of a regular ActionForm are created by first defining the instance variable and then adding a getter and setter for that instance variable. A DynaActionForm has no associated Java class. Its JavaBeans properties are created by adding the <form-property> tag in Struts Config file (and also declaring its Java type). In above RegisterForm is declared as a DynaActionForm with JavaBeans properties. The type attribute of the <form-property> is the fully qualified Java class name for that JavaBeans property; it cannot be a primitive. For instance int is not allowed. Instead you should use java.lang.Integer. You can also initialize the form property,so that the html form shows up with an initial value.