Using Definitions
The tiles shown so far add value
to an application because they organize the layout of a page in a
single resource, the layout JSP page. This can save development time
and, more importantly, the time it takes to change the layout for an
application. However, there is a problem with the approach used in
the Storefront application shown earlier. In each of the non-layout
tiles, there is redundant code that specifies what content to use for
the header, menubar, and
copyright content—the same attributes are
being passed in every page. This may not always be the case, but in
general, these values will be constant throughout an application. For
instance, the same copyright is typically shown on every page.
It’s redundant to have to specify these in every tile. Ideally, we could declare these attributes in one place, and the tiles could include just the page-specific attributes where needed. Tiles definitions provide just such functionality. A definition allows you to statically specify the attributes that are used by a template, which in turn allows you to specify only the page-specific attributes in your tiles. Definitions enable you to:
Screen definitions
Centralize declaration of page description
Avoid repetitive declaration of nearly identical pages (by using definition inheritance)
Avoid creation of intermediate components used to pass parameters
Specify the name of a definition as a
forwardin the Struts configuration fileSpecify the name of a definition as component ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access