occupation}
In place of this code, add the following line:
Chapter 5
[ 129 ]
Run the application, log in to be able to view the collection, and you should see the
following result:
Quite an impressive result for a single short line of code, isn't it? Not only are our
celebrities now displayed in a neatly formatted table, but also, we can sort the
collection by clicking on the columns' headers. Also note that occupation now has
only the first character capitalized??”much better than the fully capitalized version we
had before.
Here, we see the results of some clever guesses on Tapestry's side. The only required
parameter of the Grid component is source, the same as the required parameter of
the Loop component. Through this parameter, Grid receives a number of objects of
the same class. It takes the first object of this collection and finds out its properties. It
tries to create a column for each property, transforming the property's name for the
column's header (for example, lastName property name gives Last Name column
header) and makes some additional sensible adjustments like changing the case of
the occupation property values in our example.
Pages:
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176