Table of Contents Previous Section

Binding the Class's Instance Variables to the Form Elements

In the first chapter, you bound the input elements to variables in Main's code. Now you'll modify the bindings to use the class you just created.

  1. Select Web Components in the first column of the browser.

  2. Double-click Main in the second column of the browser to open the component in WebObjects Builder.

  3. Using the Add Variable/Method panel, add a variable called currentGuest to your component and specify its type as Guest. (Note that you can now choose Guest from the Type pop-up menu.)

    An entry for currentGuest appears in the object browser. Notice the ">" symbol to the right of its name. This means that there is additional data to be displayed in the second column.

  4. Select currentGuest in the object browser.

    The second column displays the three fields of currentGuest, as determined by the definition of its class, Guest.

  5. Click guestName in the second column of the object browser next to currentGuest and drag the cursor to the Name text field.

    This time, when the Inspector opens, there is already a binding for the value attribute (guestName), because you bound it in the first tutorial.

  6. Double-click the row containing the value binding.

    This removes the binding for guestName you made previously and binds currentGuest.guestName to the value attribute.

  7. Bind the other two input elements to currentGuest.email and currentGuest.comments.

Table of Contents Next Section