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:
- In the Project Navigator of the Web perspective, right-click the name of a project.
- Click New > Other > Web > Struts > Form-Bean Mapping > Next.
- On the "New Form-Bean" page, complete the following steps:
- Make sure that the correct configuration file name and mapping name are specified.
- Click one of the following radio buttons:
- An existing ActionForm
- Create an ActionForm class or Struts dynaform using DynaActionForm
- 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.
- Click Next.
- 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.
- 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.
- On the "Create a mapping for your ActionForm class" page, click the Add new ActionForm class box and complete the following steps:
- Specify the name for the new ActionForm class.
- Specify the path name of the folder in which the class will be created, or accept the default.
- Specify the name of the Java package, or accept the default.
- Click any of the check boxes that describe the characteristics of the class that you want to create:
- public
- abstract
- final
- Specify the name of the superclass in which the class will be created, or accept the default.
- For each interface that you want to create, click Add and type the interface name, the names of matching types, and any qualifiers.
- 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)
- Click Finish.
Related concepts
Struts form beans
Struts dynaforms
Related tasks
Creating a Struts form bean
Feedback