Java Reference
In-Depth Information
</jsp-config>
</web-app>
As a final step, I will include the layouts in the decorator configuration for the filter to
work. Listing 3-56 shows the decorator configuration.
Listing 3-56. WEB-INF/decorators.xml
<decorators defaultdir="/WEB-INF/decorators">
<decorator name="primaryLayout" page="primaryLayout.jsp">
<pattern>*</pattern>
</decorator>
</decorators>
The decorators.xml is the externalized class that manages the layout. The page attrib-
ute in the decorator tag defines the layout to be applied for the request patterns. The
primaryLayout will be applied to all the requests as evident from the pattern tag. So, when
a request for /createPolicy.do is handled by the front controller and the response is
handed over to the SiteMesh filter, it performs the following activities to manipulate and
generate the final response:
• Extract the content of the title tag, and apply it in the primary layout.
• Extract the head tag, and use it in the primary layout.
• Extract the content from the body tag, and use it in primary layout.
Using Apache Tiles
Spring MVC also provides integration with the Apache Tiles framework. Just like
SiteMesh, Tiles is a flexible and highly extensible framework that earlier worked primarily
with the Struts web framework. As of Tiles 2, it works independently as a flexible, feature-
rich layout framework. Both SiteMesh and Tiles 2 are powerful layout frameworks, and
the choice of which one to use is basically a matter of taste and expertise. The following
link in the Spring documentation provides a step-by-step guide to integrating Spring and
Tiles 2:
http://static.springframework.org/spring/docs/2.5.x/reference/view.html#view-tiles
 
Search WWH ::




Custom Search