Java Reference
In-Depth Information
as a default. The Login and Registration pages can use
layout_main.jsp
without providing the
"menu"
component.
Next, the
layout_menu.jsp
file uses
layout_main.jsp
and provides the
"menu"
component:
<s:layout-definition>
<s:layout-render name="/WEB-INF/jsp/common/layout_main.jsp"
title="${title}">
<s:layout-component name="menu">
(menu will go here)
</s:layout-component>
<s:layout-component name="body">
${body}
</s:layout-component>
</s:layout-render>
</s:layout-definition>
Notice that the content for the
"title"
attribute and
"body"
component
must be taken from the renderer and sent to the layout even if they are
not modified; otherwise, the content from the renderer would be lost.
Indeed, when a JSP “A” renders a layout “B” and “B” renders another
layout “C,” content is not automatically transmitted from “A” to “C”—it
is the responsibility of “B” to do so.
Finally,
layout_folders.jsp
uses
layout_menu.jsp
and decorates the
"body"
component to add the folders on the left:
<s:layout-definition>
<s:layout-render name="/WEB-INF/jsp/common/layout_menu.jsp"
title="${title}" currentSection="${currentSection}">
<s:layout-component name="body">
<div id="folders">
(folders go here)
</div>
<div id="main">
${body}
</div>
</s:layout-component>
</s:layout-render>
</s:layout-definition>
This brings us to another interesting feature that we want in sophisti-
cated reusable layouts. The menu and folders are in layouts and used
in multiple pages, but their content is not static. It changes constantly:
the menu switches the highlighted section according to what the user
selects, and the folders are updated as messages are added, moved,
and deleted.
Search WWH ::
Custom Search