It
does three things:
1. It accepts a number of objects through its source parameter. In our case we
used the t:source="allCelebrities" attribute, and so Tapestry will be
looking for a getAllCelebrities method in the page class to provide some
number of objects (they can be provided as an ArrayList, a HashSet or any
other Java class that implements an iterable interface).
2. It iterates through the provided collection and displays its body (i.e.
whatever is surrounded by the Loop component) as many times as there
are objects in the collection. When the Loop component is embedded into
an HTML element, it will display its body surrounded by that element. In
our case, we have embedded Loop into the
element, and as a result,
the component will display as many table rows as there are objects in the
provided collection.
Simple Components
[ 98 ]
3. Every time it iterates through an object, Loop makes that object available to
the page class through the component's value parameter. In our case we
used the t:value="celebrity" attribute which means that Tapestry will
be looking for setCelebrity() in the page class, and it will pass the current
object iterated through by Loop as a parameter to that method.
Pages:
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136