As you can see from Figure 17-9, the template requires the following page components:
/WEB-INF/views/header.jspx: This page provides the header area.
·
/WEB-INF/views/menu.jspx: This page provides the left menu area, as well as the
·
login form that will be implemented later in this chapter.
/WEB-INF/views/footer.jspx: This page provides the footer area.
·
We will use Apache Tiles to define the template, and we need to develop the page template file as
well as the layout definitions file, as listed here:
/WEB-INF/layouts/default.jspx: This page provides the overall page layout for a
·
specific template.
/WEB-INF/layouts/layouts.xml: This file stores the page layout definitions
·
required by Apache Tiles.
Implement Page Layout Components
Having the layout defined, we can implement the page components. First we will develop the page
template file and the layout definition files required by Apache Tiles.
Listing 17-19 shows the Apache Tiles definition file (src/main/webapp/WEB-INF/layouts.xml).
Listing 17-19. Apache Tiles Definition File
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN"
"http://tiles.apache.org/dtds/tiles-config_2_1.dtd">
<tiles-definitions>
<definition name="default" template="/WEB-INF/layouts/default.jspx">
<put-attribute name="header" value="/WEB-INF/views/header.jspx" />
<put-attribute name="menu" value="/WEB-INF/views/menu.jspx" />
<put-attribute name="footer" value="/WEB-INF/views/footer.jspx" />
</definition>
</tiles-definitions>
The file should be easy to understand. There is one page template definition, with the name
default. The template code is in the file default.jspx. Within the page, three components are defined,
named header, menu, and footer. The content of the components will be loaded from the file provided by
the value attribute. For a detailed description of the Tiles definition, please refer to the project
documentation page (http://tiles.apache.org/2.2/framework/tiles-core/dtddoc/index.html).
Listing 17-20 shows the default page template (default.jspx).
Listing 17-20. The Default Template File
<html xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:tiles="http://tiles.apache.org/tags-tiles"
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home