Repetitions – Apple WebObjects 3.5 Tools And Techniques User Manual
Page 78

Chapter 3
Working With Dynamic Elements
78
Repetitions
A repetition (WORepetition) is a container element that repeats its contents a
certain number of times. It is like a loop in a structured programming language.
Repetitions are one of the most important elements in WebObjects, since it is
quite common for applications to display repeated data (often from databases)
when the amount of data to be displayed isn’t known until run time. Typically,
a repetition is used to generate items in a list, multiple rows in a table, or
multiple tables.
To create a repetition:
1. Click .
The repetition appears in the component window.
2. Add elements inside the repetition (replacing the word “Repetition”).
A repetition can contain any other elements, either static HTML or
dynamic WebObjects elements.
3. Alternatively, you can select existing elements, then click
to wrap the
repetition around the elements. This is necessary in some cases, such as
wrapping a repetition around a table row.
You usually bind two attributes of a repetition:
list
and
item
. The
list
attribute must
be bound to an array. WebObjects generates the elements in the repetition once
for each item in the array. Each time through the array, the
item
attribute points
to the current array object. Typically, you bind
item
to a variable and then use that
variable in the bindings of the elements inside the repetition.
When you drag an item from the object browser to the WORepetition to bind
it, the default attribute shown in the Inspector depends on whether the item is
an array. If it is,
list
is the default attribute; otherwise,
item
is the default attribute.
In addition, as with WOStrings, WebObjects Builder provides a shortcut for
binding repetitions so that you don’t have to use the Inspector. Drag to the first
binding box to bind the
list
attribute; drag to the second box to bind the
item
attribute.
Drag to here to bind the
item
attribute directly.
Drag to here to bind the
list attribute directly.
Add elements here.