Different Types of Form Bean in Struts 1.X

What is Form Bean :

A form bean is a type of Java bean. A form bean is an instance of a subclass of an ActionForm class and other FormBean class, which stores HTML form data from a submitted client request or that can store input data from a Struts action link that a user clicked.
You can divide Form Beans into two types.

  1. Static Forms
  2. Dynamic Forms


Static Forms :

There are three types of Static Forms.

  • ActionForm
  • ValidatorForm
  • ValidatorActionForm

What is Form Bean :

A form bean is a type of Java bean. A form bean is an instance of a subclass of an ActionForm class and other FormBean class, which stores HTML form data from a submitted client request or that can store input data from a Struts action link that a user clicked.
You can divide Form Beans into two types.

  1. Static Forms
  2. Dynamic Forms


Static Forms :

There are three types of Static Forms.

  • ActionForm
  • ValidatorForm
  • ValidatorActionForm




When you are using the Static Form, you need to do the following things.

  • You need to write a Java class by extending one of the above mentioned Static Forms.
  • You need to declare the fields same as JSP forms.
  • You need to write the set/get methods for all the fields.
  • If you want to validate form data you need to override the validate() method in the Form Bean class.
  • If you want to reset your form fields ,you need to override the reset() method in the Form Bean class.



Dynamic Forms :

There are three types of Dynamic Forms.

  • DynaActionForm
  • DynaValidatorForm
  • DynaValidatorActionForm

When you are using the Dynamic Form, you need to do the following things

  • Write the field declaration inside the struts configuration file(No need to write Java class with private field and set/get method).
  • DynamicForms will reset automatically to default values(No need to override reset method).
  • Dynamic forms will use validation framework for the form validations (No need to override the validate method)





comments powered by Disqus