< Previous | Next >

Lesson 3: Create a form bean

Learn how to create a form bean.

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

To create a form bean:

  1. In the diagram, hold the mouse pointer over the /computeDay action and click Add Form Bean.
    On the hover menu of the /computeDay action, the mouse pointer is on the Add Form Bean icon.
  2. In the Form Bean Selection dialog, click New. The New Form Bean wizard opens.
  3. In the Form Bean Name field, type dateData. Click Next.
  4. On the Create new fields for your ActionForm class page of the wizard, click Add to add the following fields:
    Name Type
    year int
    month int
    day int
    dayOfWeek String

    Then click Next.

  5. On the Create a mapping for your ActionForm class page of the wizard, in the Java package field, type com.ibm.dayofweek. Click Finish. The Form Bean Selection dialog displays the form bean that you just created.
  6. In the Form Bean Selection window, select dateData, then click OK. The /computeDay node is updated with the form bean.
The dateData form bean is added to the /computeDay node, and the dateData.java file is created in DayOfWeek\Struts\<default module>\Form Beans.
At the end of this lesson, the Enterprise Explorer looks like this:
The Enterprise Explorer highlights the dateData file.

Lesson checkpoint

In this lesson, you created the dateData form bean and defined the ActionForm class.
You learned to do these tasks:
  • Bring up the hover menu.
  • Define the parameters of the ActionForm class.
  • Locate a Java file in the Web project folder in the Enterprise Explorer.
< Previous | Next >

Feedback