The Definitions Configuration File

Now that Tiles is installed, you can write the definitions file. Listing 16.1 shows the definitions for the Stocktracker application.

Listing 16.1. The Tiles Layout Definition File (stocktrack-tiles.xml)
<!DOCTYPE tiles-definitions PUBLIC
  "-//Apache Software Foundation//DTD Tiles Configuration//EN"
  "http://jakarta.apache.org/struts/dtds/tiles-config.dtd">

<tiles-definitions>
 <definition name="stocktrack.default" path="/layouts/stocktrackDefault.jsp">
  <put name="header" value="/header.jsp" />
  <put name="minibar" value="/minibar.jsp" />
 </definition>
 <definition name="stocktrack.index" extends="stocktrack.default">
  <put name="mainwindow" value="/home.jsp" />
  <put name="title" value="Welcome to Stock Tracker"/>
 </definition>
 <definition name="stocktrack.portfolio" extends="stocktrack.default">
  <put name="mainwindow" value="/portfolio.jsp" />
  <put name="title" value="Portfolio View"/>
 </definition>
 <definition name="stocktrack.newUserName" extends="stocktrack.default">
  <put name="mainwindow" value="/newUserName.jsp" />
  <put name="title" value="Enter User Information"/>
 </definition>
 <definition name="stocktrack.newUserAddress" extends="stocktrack.default">
  <put name="mainwindow" value="/newUserAddress.jsp" />
  <put name="title" value="Enter User Address"/>
 </definition>
</tiles-definitions>

The file is composed of a number of definition tags bounded by a tiles-definitions tag. Each definition tag corresponds to a page in the application.

Note

The names of the definitions can be totally arbitrary. They don’t need to correspond to any package definition or path. You could name a definition starship.enterprise if you wanted to. The definition’s name merely serve as a unique identifier that you can use in place of JSP paths in a forward, input, or path directive.

However, that having been said, it makes sense to use some kind of hierarchical or package-based naming convention to keep things straight.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset