Java Reference
In-Depth Information
body of the <s:layout-component> tag used in the layout. You can still
override the content in a renderer, but you can omit the component
altogether in all those pages that use the default content.
For example, this layout has three components: part1 , part2 , and part3 :
Download reusable_layouts/web/default_content/layout.jsp
<s:layout-definition>
Header
<div>
<s:layout-component name="part1">
Default Part 1
</s:layout-component>
</div>
<div>
<s:layout-component name="part2">
Default Part 2
</s:layout-component>
</div>
<div><s:layout-component name="part3"/></div>
Footer
</s:layout-definition>
The following renderer renders the layout:
Download reusable_layouts/web/default_content/renderer.jsp
<s:layout-render name="/default_content/layout.jsp">
<s:layout-component name="part2">
My Part 2
</s:layout-component>
</s:layout-render>
And produces the following:
Header
Default Part 1
My Part 2
Footer
The renderer does not provide content for part1 , so the layout's default
is used. The renderer's content overrides the layout's default for part2 .
For the part3 component, neither the layout nor the renderer provides
content. Layouts are more forgiving than abstract classes here: empty
components don't cause errors; they are just left blank.
Using Attributes
Besides the <s:layout-component> tag, a renderer can also send con-
tent to a layout with dynamic attributes of the <s:layout-render> tag.
 
 
Search WWH ::




Custom Search