Lesson 1.3: Creating a form bean

A form bean is a type of Java™ bean that stores HTML form data from a submitted client request or stores input data from a Struts action link that a user clicked.

To create a form bean:

  1. Hover over the /computeDay action and click the Form bean icon. Shows /computeDay action with hover menu
  2. The Form bean selection window opens.
  3. Click New. The New Form-Bean wizard opens.
  4. In the Form Bean Name field, type dateData, then click Next.
  5. On the Choose new fields for your ActionForm class page, select the DayOfWeek check box and click Next.
  6. On the Create new fields for your ActionForm class page, add the following fields using the Add button:
    Option Description
    Name Type
    year int
    month int
    day int
    dayOfWeek String
  7. Click Next.
  8. On the Create a mapping for your ActionForm class page in the Java package field type com.ibm.dayofweek.
  9. Click Finish.
  10. In the Form Bean Selection window, click the dateData form bean you just created, then click OK.
The form bean dateData is added to the computeDay node and the actual resource dateData.java is created in your Web project folder. Navigate to DayOfWeek > Struts > <default module> > Form Beans to see the file.
At the end of this lesson, the Project Explorer should resemble: dateData file

Lesson checkpoint

You are able to create a dateData form bean and define the ActionForm class.

You learned:
  • To bring up the hover menu.
  • To define the parameters of the ActionForm class.
  • To locate the .java file in the Web project folder in the Project Explorer.