Java Reference
In-Depth Information
For example, look at the following layout and renderer:
Download reusable_layouts/web/attributes/layout.jsp
<s:layout-definition>
Ê
Header: ${title}
<div><s:layout-component name="body"/></div>
<div>
Objects:
<ul>
Ë
<c:forEach var="object" items="${objects}">
<li> ${object} </li>
</c:forEach>
</ul>
</div>
Footer
</s:layout-definition>
Download reusable_layouts/web/attributes/renderer.jsp
Ê
<s:layout-render name="/attributes/layout.jsp" title="My Title"
Ë
objects="${pageContext.request.parameterMap}">
<s:layout-component name="body">
Hello, reusable layout
</s:layout-component>
</s:layout-render>
At Ê in renderer.jsp , the title attribute has the value "My Title" . The layout
can put this value in the page using the attribute name within ${ } , as
in ${title} at Ê in layout.jsp . Attributes are not components, so <s:layout-
component name="title"/> won't work in the layout to display "My Title" .
As you can see, attributes are more concise and are good for short
content. They also give you a way to send types other than String from
a renderer to a layout. At Ë in renderer.jsp , the objects attribute is a
Map<String,String[ ]> , and the layout receives a value of that type. In this
example, the layout iterates over the values of the list in
Ë
of layout.jsp
and outputs each item. With these request parameters:
dir=example&files=one&files=two
renderer.jsp produces the following:
Header: My Title
Hello, reusable layout
Objects:
o dir=[example]
o files=[one, two]
Footer
 
 
Search WWH ::




Custom Search