|
Cedric, very briefly tried adding flush="true" to
all
<template:get ...> tags, resulted in the following error: org.apache.jasper.JasperException: Attribute flush invalid according to the specified TLD. Jon, the browser used is IE5.5, there weren't any
exceptions to the console. I've attached the source for the generated html,
hopefully this will provide some clues, seems the template is being
rendered at the bottom of the page minus the
content.
|
<font size='5'><a name="top">Topics</a></font><p>
<table width='145'>
<tr><td><a href='http://localhost:8080/jsptemplates/jsp/introduction.jsp'>
Introduction </a></td></tr>
<tr><td><a href='http://localhost:8080/jsptemplates/jsp/using.jsp'>
Using Templates </a></td></tr>
<tr><td><a href='http://localhost:8080/jsptemplates/jsp/optional.jsp'>
Optional Content </a></td></tr>
<tr><td><a href='http://localhost:8080/jsptemplates/jsp/more.jsp'>
... and more ...</a></td></tr>
</table></p>
<table>
<tr>
<td><img src='http://localhost:8080/jsptemplates/graphics/java.gif'/></td>
<td><img src='http://localhost:8080/jsptemplates/graphics/templates.gif'/></td>
</tr>
</table><hr>
<p class="Paragraph"><i>This example application is based on <a
href="http://www.javaworld.com/javaworld/jw-09-2000/jw-0915-jspweb_p.html">Using JSP
templates to encapsulate Webpage layout and encourage modular design</a> by David
Geary. Follow that link for the full article, which also covers using role-based and
nested templates. The template classes described in the Java World article were the
basis for those included with Struts 1.0.</i></p>
<h3 class="ChapTitle">Introduction</h3>
<p class="Paragraph">Window toolkits typically provide a layout mechanism that
positions widgets in a container; for example, AWT and Swing have layout managers,
whereas VisualWorks Smalltalk has wrappers.</p>
<p class="Paragraph">Because layout undergoes many changes over the course of
development, it's important to encapsulate that functionality so layout can be
modified with minimal impact to the rest of the application. In fact, layout managers
are an example of one of the tenets of object-oriented design: encapsulate the concept
that varies, which is also a fundamental theme for many design patterns.</p>
<p class="Paragraph">JSP does not provide direct support for encapsulating layout, so
web pages with identical formats usually replicate layout code; for example, <b>A Web
Page Layout</b> shows a web page containing sections for a header, footer, sidebar,
and main content.</p>
<p class="Paragraph">The layout of the page shown in <b>A Web Page Layout</b> is
implemented with HTML table tags, as listed in Including Content.</p>
<p><img src="http://localhost:8080/jsptemplates/graphics/templates-1.gif"></p>
<h4 class="CodeCaption">Including Content</h4>
<p class="Example-Code">
<html><head><title>Templates</title></head><br>
<body
background='http://localhost:8080/jsptemplates/graphics/blueAndWhiteBackground.gif'></p>
<p class="Example-Code">
<table width='610'><br>
<tr valign='top'><td><jsp:include page='sidebar.jsp'/></td><br>
<td><table><br>
<tr><td><jsp:include page='header.html'/></td></tr><br>
<tr><td><jsp:include page='chapter.jsp'/></td></tr><br>
<tr><td><jsp:include page='footer.jsp'/></td></tr><br>
</table><br>
</td><br>
</tr> <br>
</table><br>
</body></html></p>
<p class="Paragraph">In Including Content, content is included with <jsp:include>
which allows content to vary without modifying HTML; however, because the layout is
hardcoded, layout changes require modifications to the page. If a website has many
pages with identical formats, even simple layout changes require modifications to all
of the pages.</p>
<h4 class="ChapTitle">Using A Template</h4>
<br>
<p class="Example-Code">
<%@ taglib URI='/WEB-INF/struts-template.tld' prefix='template' %></p>
<p class="Example-Code">
<template:insert template='/chapterTemplate.jsp'><br>
<template:put name='title' content='Templates' direct='true'/><br>
<template:put name='header' content='/header.html'/><br>
<template:put name='sidebar' content='/sidebar.jsp'/><br>
<template:put name='content' content='/introduction.html'/><br>
<template:put name='footer' content='/footer.html'/><br>
</template:insert></p>
<p class="Paragraph">To minimize the impact of layout changes, a mechanism is needed
for dynamically including layout in addition to content. That way, both layout and
content can be changed without modifying files that use them. For large websites that
have many pages with identical formats, such a mechanism is valuable because it
localizes changes to layout. That mechanism is JSP templates.</p>
<hr><p align="right"><a href='#top'><font size="1">TOP</font></a></p>
<html>
<head>
<title>Templates</title>
<link rel="stylesheet" href="http://localhost:8080/jsptemplates/css/templates.css"
charset="ISO-8859-1" type="text/css">
</head>
<body
background='http://localhost:8080/jsptemplates/graphics/blueAndWhiteBackground.gif'>
<table>
<tr valign='top'>
<td></td>
<td><table>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
</table>
</td>
</tr>
</table>
</body>
</html>

