beautypg.com

Apple WebObjects 3.5 User Manual

Page 54

background image

Chapter 2

Enhancing Your Application

54

You’ll bind the

allGuests

array to the WORepetition’s

list

attribute. This tells

WebObjects to generate the elements in the repetition once for each item in the
array. Each time WebObjects iterates through the array, it sets the repetition’s

item

attribute to the current array object. You bind

item

to the variable

currentGuest

and use

currentGuest

’s fields to bind the elements inside the repetition (such as

WOStrings). At run time, the table will consist of one row (displaying name,
e-mail address, and comments) for each guest.

1. In WebObjects Builder, make the Main component window active.

2. Select the table at the bottom of the page by clicking outside it and dragging

across it.

3. Choose Edit

m

Copy.

4. Make the GuestList component active.

5. Place the cursor at the bottom of the page and choose Edit

m

Paste.

You have just copied the table from Main into GuestList. It has all the
same properties, including the bindings. The WOStrings in the table are
still bound to instance variables of

currentGuest

. Since

currentGuest

is a

component variable defined in Main, it isn’t accessible from GuestList.
Therefore, you need to declare it here.

6. From the pull-down menu at the bottom of the window, choose Add

Variable/Method. Enter

currentGuest

as the name of the variable and

Guest

as its type.

7. Choose

from the Elements pop-up list to display the Tables buttons.

8. Click somewhere in the table, then click

in the toolbar to enter

structure-editing mode. (Alternatively, Control-click on the table.)

9. Click one of the triangles in the second row to select the entire row.

10. Choose

to display Other WebObjects in the toolbar and click

When you wrap a repetition around a table row in this way, the

WORepetition symbol

doesn’t appear in the table. Instead, a blue

border appears around the row. For additional examples of using
repetitions, see Chapter 3, “Creating a WebObjects Database Application”
(page 59).