Creating Struts form-bean mappings

A form bean is an instance of a subclass of an ActionForm 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. A form-bean mapping is an entry in a Struts configuration file that maps a form bean to an action.

To create a Struts form-bean mapping, complete the following steps:

  1. In the Project Navigator of the Web perspective, right-click the name of a project.

  2. Click New > Other > Web > Struts > Form-Bean Mapping > Next.

  3. On the "New Form-Bean" page, complete the following steps:

    1. Make sure that the correct configuration file name and mapping name are specified.

    2. Click one of the following radio buttons:

      • An existing ActionForm

      • Create an ActionForm class or Struts dynaform using DynaActionForm

    3. If you selected the second choice in the previous step, you must select one of the following models from the drop-down menu:

      • Generic Form-Bean Mapping

      • dynaform using DynaActionForm

      A dynaform is basically a dynamic form bean. For a generic form bean, create both a form bean and a form-bean mapping. To create a dynaform, you need create only a form-bean mapping; a form bean will be dynamically created for you at run time. However, the form-bean mapping required to specify a dynaform is substantially more complex than that required merely to complement a generic form bean.

    4. Click Next.

  4. On the "Choose new fields for your ActionForm class" page, click the check box beside the name of each module for which you want a get and a set method created. Then click Next.

  5. On the "Create new fields for your ActionForm class" page, click Add and type the field name and type for each field you want to create. If you chose Generic Form-Bean Mapping, click Next; otherwise click Finish.

  6. On the "Create a mapping for your ActionForm class" page, click the Add new ActionForm class box and complete the following steps:

    1. Specify the name for the new ActionForm class.

    2. Specify the path name of the folder in which the class will be created, or accept the default.

    3. Specify the name of the Java package, or accept the default.

    4. Click any of the check boxes that describe the characteristics of the class that you want to create:

      • public

      • abstract

      • final

    5. Specify the name of the superclass in which the class will be created, or accept the default.

    6. For each interface that you want to create, click Add and type the interface name, the names of matching types, and any qualifiers.

    7. Click the check boxes for the method stubs that you want created, or accept the defaults. The choices are as follows:

      • inherited abstract methods

      • constructors from superclass

      • reset(..., HttpServletRequest)

      • reset(..., ServletRequest)

      • validate(..., HttpServletRequest)

      • validate(..., ServletRequest)

    8. Click Finish.

 

Related concepts

Struts form beans
Struts dynaforms

 

Related tasks

Creating a Struts form bean

Feedback