Lesson 3: Create a form bean
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:
- In the diagram, hold the mouse pointer over the /computeDay action and click
Add Form Bean.
The Form Bean Selection dialog opens.
- In the Form Bean Selection dialog, click New.
The New Form Bean wizard opens.
- In the Form Bean Name field, type dateData.
- Click Form Bean Type to create the form bean type specified by the class. The New ActionForm Class dialog opens.
- 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.
- 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.
- 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.
- 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:
- 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.