Expert Spring MVC and Web Flow

(Dana P.) #1

Tiles


Let’s take a brief look at Tiles integration before moving to non-JSP view types. Tiles allows
you to define separate page components (the tiles) that can be configured independently and
reused in different page layouts. It was originally a JSP-based technology that grew out of the
Struts project and is now considered independent from that framework, although you will
still need to include struts-1.1.jaror later to use Tiles in your view layer. You’ll also need
Commons-BeanUtils, Commons-Digester, and Commons-Langin your classpath.
To get started with Tiles, you must configure it. You can do this with a TilesConfigurer
bean instance in your DispatcherServlet’s configuration file. Listing 8-13 offers just such an
example.


Listing 8-13.Tiles Configuration Bean


<bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles.TilesConfigurer">




/WEB-INF/tiles/defs-main.xml
/WEB-INF/tiles/defs-other.xml



In the configuration bean we tell the Tiles subsystem to load definitions (Tiles configura-
tions) from two files located in WEB-INF/tiles. Listing 8-14 shows the trivial defs-main.xml
defining a single home page layout with a single content tile named content.


Listing 8-14.Tiles Definition Configuration for the Home Page


<?xml version="1.0" encoding="ISO-8859-1" ?>


<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">



<!-- DEFAULT MAIN TEMPLATE -->
<definition name="home"page="/WEB-INF/jsp/tiles-home.jsp">
<put name="content" value="/WEB-INF/jsp/home.jsp" type="page"/>
</definition>


CHAPTER 8 ■SUPPORTED VIEW TYPES 233
Free download pdf