Java Reference
In-Depth Information
produces this:
Header
My Ads Left
My Menu Hello, reusable layout
My Ads Right
Footer
Notice that the order in which we specify components in a renderer does
not matter—what matters is where the layout places the components
within the template.
Default Content in Layout Decorators
The components in the last layout_decorator.jsp are "adsLeft" , "menu" ,
"body" , and "adsRight" . We can also provide default content for these
components. It's straightforward for "adsLeft" and "adsRight" : just add
the default in the body of the <s:layout-component> tag. But how
do we provide a default for "menu" and "body" , where we can't use the
<s:layout-component> tag?
Remember a component can also be placed in the layout using the com-
ponent name within ${ } , such as ${menu} and ${body} . That's because
components are in the JSP's context. We can set a value in the same
context with the JSTL's <c:set> tag, as shown here:
Download reusable_layouts/web/default_content_in_decorators/layout_decorator.jsp
<c:set var="menu"> Default Menu </c:set>
<c:set var="body"> Default Body </c:set>
<s:layout-definition>
<table>
<tr><td>
<s:layout-component name="adsLeft">
Default Ads left
</s:layout-component>
</td><td>
<s:layout-render name="/default_content_in_decorators/layout.jsp">
<s:layout-component name="body">
<table><tr>
<td> ${menu} </td>
<td> ${body} </td>
</tr></table>
</s:layout-component>
</s:layout-render>
</td><td>
 
 
Search WWH ::




Custom Search