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.
- Select Web Components in the first column of the browser.
- Double-click Main in the second column of the browser to open the component in WebObjects Builder.
- 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.)
- Select currentGuest in the object browser.
- Click guestName in the second column of the object browser next to currentGuest and drag the cursor to the Name text field.
- Double-click the row containing the value binding.
- Bind the other two input elements to currentGuest.email and currentGuest.comments.
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.
The second column displays the three fields of currentGuest, as determined by the definition of its class, Guest.
This time, when the Inspector opens, there is already a binding for the value attribute (guestName), because you bound it in the first tutorial.
This removes the binding for guestName you made previously and binds currentGuest.guestName to the value attribute.
Table of Contents Next Section