Creating Struts form beans

This documentation describes how to create a Struts form bean and optionally create a form-bean mapping.

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 and optionally create a form-bean mapping, complete the following steps:

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

  2. Click New > Other > Web > Struts > ActionForm Class > Next.

  3. On the New ActionForm Class page in the ActionForm class name field, type the name of the ActionForm subclass that you are creating.

  4. Fill out the other fields as appropriate for the subclass you are creating, and click Next.

  5. On the "Choose new fields for your ActionForm class" page, click the check box beside the name of each node for which you want a get and a set method created. Check boxes exist for every node in the following hierarchy:

    • Project

    • Module

    • Folder

    • Web page

    • Form

    • Form field (leaf)

    If you click the check box beside the name of a form field, you will generate a corresponding field, get method, and set method in your form bean. If you click the check box beside the name of a parent, you will generate a corresponding field, get, and set for every leaf underneath that parent. Then click Next.

  6. 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 want to create a form-bean mapping, click Next. Otherwise click Finish and skip the final step.

  7. On the "Create a mapping for your ActionForm class" page, make sure that the Add new mapping box is checked and that the correct configuration file name and mapping name are specified. Then click Finish.

 

Related concepts

Struts form beans
Struts dynaforms

 

Related tasks

Creating Struts form-bean mappings

Feedback