Java Reference
In-Depth Information
Each page specifies a title, which the layout places at Ê and Ì , and
a body, which is placed at Í . The layout provides a common HTML
structure and imports style.css (a cascading style sheet) at
Ë using that
convenient ${contextPath} shortcut I mentioned earlier.
With the layout_main.jsp file, we've created the page declaration, header,
CSS file, and body structure for every page of the application. Instead
of repeating all that code each time we add a JSP, we render the layout
and need to specify only the title and the body contents. For example,
this JSP:
<%@include file="/WEB-INF/jsp/common/taglibs.jsp"%>
<s:layout-render name="/WEB-INF/jsp/common/layout_main.jsp"
title="My Title">
<s:layout-component name="body">
My page content
</s:layout-component>
</s:layout-render>
produces the following result:
<html>
<head>
<title> My Title </title>
<link rel="stylesheet" type="text/css"
href="/myapp/css/style.css"/>
</head>
<body>
<div id="header">
<span class="title"> My Title </span>
</div>
<div id="body">
My page content
</div>
</body>
</html>
Pretty cool, no? Let's take a quick break here, and you can have a cold
glass or hot cup of your favorite drink. Then we'll write the action bean
and JSP for retrieving and displaying the contact list.
3.3
Displaying Data with Action Beans and JSPs
Let's display the list of contacts in a table. The best way to do this in
Stripes is to write an action bean that obtains the list from the DAO
and makes it available in a getter method. Then it's easy to write a JSP
that retrieves the list from the action bean and renders it in an HTML
table. That's all we need, clean and simple.
 
 
 
Search WWH ::




Custom Search