Table of Contents Previous Section

Creating Variables

In this section, you'll declare individual variables in your code file (Main.java) to hold the name, e-mail address, and comments entered by a single guest. Later on, you'll structure this information differently in order to work with data from multiple users.

WebObjects Builder allows you to declare variables without having to edit your source file directly. At the bottom of the window there is a pull-down menu called Edit Main.java. It has three items:

  1. Choose Add Variable/Method from the pull-down menu.

    The Add Variable/Method panel opens.

  2. Type guestName in the Name field.

  3. To specify the variable's type, select String from the pop-up menu (or you can type String directly in the box.

  4. Click Add.

    You have just created a variable called guestName of type String. It appears in the first column of the object browser. A declaration for guestName also appears in Main.java, which you'll edit later.

  5. Create the variables email and comments in the same way (they are also of type String.)

Table of Contents Next Section