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.
- Click .
- Add elements inside the repetition (replacing the word "Repetition").
- 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.
The repetition appears in the component window.
A repetition can contain any other elements, either static HTML or dynamic WebObjects elements.
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.
When you wrap a repetition around a table row, the repetition symbol doesn't appear. Instead, a blue border appears around the row. To bind the repetition, drag from the object browser to anywhere in the row (but not to a dynamic element inside the row). The Inspector appears, allowing you to complete the binding as usual.
Note: You can also wrap a repetition around a single cell in a table. In addition, this same procedure of wrapping a repetition around a table row or cell also works for conditionals (see next section).