Java Reference
In-Depth Information
Stripes layout mechanism, but here's a quick introduction. All we need
is three tags:
•
<s:layout-definition>
in
some.jsp
This identifies
some.jsp
as a reusable layout.
•
<s:layout-render name="/path/to/some.jsp">
in
another.jsp
This indicates that
another.jsp
uses the
some.jsp
layout to render a
page.
•
<s:layout-component name="someName">
Within <s:layout-definition>, this tag says, “Put the contents of
the
someName
component here.” But within <layout-render>, it
means this: “Here is the contents of the
someName
component.”
The renderer sends contents to the definition, and the definition
decides where to place it within the layout. The other way for a ren-
derer to send something to a definition is with arbitrary attributes.
<s:layout-render name="..." title="My Title"> gives the definition a
title
attribute with a value of My Title. The definition can use
${title}
to place this value in the layout.
That's a fair amount of theory, but it's really quite simple. Have a look at
the code for
layout_main.jsp
, which we'll use for the webmail application:
<%@page contentType="text/html;charset=ISO-8859-1" language="java"%>
<%@include file="/WEB-INF/jsp/common/taglibs.jsp"%>
<s:layout-definition>
<!
DOCTYPE
HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
Ê
<title>
${title}
</title>
<link rel="stylesheet" type="text/css"
Ë
href="${contextPath}/css/style.css">
</head>
<body>
<div id="header">
Ì
<span class="title">
${title}
</span>
</div>
<div id="body">
Í
<s:layout-component name="body"/>
</div>
</body>
</html>
</s:layout-definition>
The
<s:layout-definition>
tag declares this JSP as a reusable layout.
Search WWH ::
Custom Search