Book Detail JSP Example
This example demonstrates how Layouts can be nested inside JSPs. It uses the same XHTML for its main content area as the other Book Detail example, which is strictly Layout-based.
Notes on this Example
The example content above is defined in BookDetail.xhtml. In addition to ErrorMessages.xhtml, which is shared by most of the examples, it includes three other nested templates. In fact, there is little else in BookDetail.xhtml other than the layout elements that nest the other components. The nested components are as follows:
TableHead.xhtml contains a THEAD element that defines the the main header area of the table. Uses custom s:formatter attributes settings to configure CSVListFormatters (which format the elements of a List as comma-separated strings) for several List properties containing, respectively, publisher's names, publication dates, nad ISBNs for the editions shown in the body of the table. One of these (the setting for the publication dates List) identifies the nestedFormatter type to use to format the List's elements, as follows:
TableBody.xhtml defines a TBODY containing two rows: the heading row immediately above the data rows, and a row that defines the repeating element. The TR for that row contains a s:collection custom attribute that configures a Collection to iterate over. The INPUT element for the Price column has an s:formatter custom attribute that includes a setting instructing the CurrencyFormatter to use the currency symbol, as follows:
s:formatter="Currency:showCurrencySymbol=true"The INPUT element in the In Stock column uses a s:validation custom attribute to specify a range as follow:
s:validation="Range:minValue=0,maxValue=500"It's more common to specify a range with a pair of minValue and maxValue settings, like so
s:minValue=0 s:maxValue=500"The example includes s:validation to provide a simple illustration of its usage. While it may not be needed frequently, this more general mechanism has the advantage of being usable with arbitrary ValidationRules and settings, including ones that don't exist in the framework, such as those your application might add.
TableFoot.xhtml contains an unremarkable TFOOT element that includes a simple INPUT element for the submit button.