They can have a template
that looks pretty similar to a Tapestry page. The component's Java class is a POJO,
just like a page class. In this class, we can inject different resources and services, create
event handlers and so on??”anything we would normally do in a page class.
The difference between a page and a component is that components often have
parameters??”pieces of information passed to them to influence their appearance
and functionality. Also, page classes are always created in the pages sub-package of
the application's package structure. Whereas component classes always go into the
components sub-package, and their templates should be placed into this sub-package
as well (or, more precisely, the templates should be placed under the same structure
of subdirectories as component classes).
There can also be components without templates. If they need to display themselves
in some way, they generate any mark up in their Java code. We are not going to
create such components, but if you want to see an example, please refer to the
Tapestry 5 User Guide (http://tapestry.apache.org/tapestry5/tapestrycore/
guide/component-classes.html).
In many cases, creating a custom component will be very similar to creating a custom
page, and this will especially be true for the component created in the next section.
Pages:
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249