< Previous | Next >

 

Lesson 3: Create a form bean

 

+

Search Tips   |   Advanced Search

 

Use this lesson to 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.

    The Form Bean Selection dialog opens.

  2. In the Form Bean Selection dialog, click New.

    The New Form Bean wizard opens.

  3. In the Form Bean Name field, type dateData.

  4. Click Form Bean Type to create the form bean type specified by the class. The New ActionForm Class dialog opens.

  5. Click Next. Since your application is new, the pages in your project do not contain any form information yet. If they did, you could pull in fields for this information here.

  6. 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 Finish.

  7. In the

    New Form-Beam page of the

    New Form-Bean dialog, click Finish. The

    Form Bean Selection dialog displays the form bean that you just created.

  8. 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:

 

Lesson checkpoint

In this lesson, you created the dateData form bean and defined the ActionForm class.

You learned to do these tasks:

< Previous | Next >