Java Reference
In-Depth Information
Joe Asks. . .
Should I Use Components or Attributes?
You
can
use
either
components
or
attributes
in
renderers.
Choosing
between
them
depends on
the
content you
are
sending to the layout:
• For multiple lines of content, you must use a component.
• For non- String content, you must use an attribute.
It also depends on how you place the content in the layout:
• If the content is placed in the layout with a component,
the renderer must use a component to provide the con-
tent.
• If the renderer specifies content with an attribute, the lay-
out must use ${ } to place the content.
• Whether the renderer uses a component or an attribute,
the layout can use ${ } to place the content.
You'll find that using components for blocks of content, and
attributes for short content or parameter-like values, generally
works out well.
The <s:layout-render> tag does not know in advance the names of
the attributes you will use, so it actually supports dynamic attributes.
This allows you to choose whatever attribute names you want to send
parameters from a renderer to a layout.
7.2
Putting Layouts to Work: Decorators
Now that we've seen the building blocks of Stripes reusable layouts,
let's put them to work beyond the “Hello, reusable layout” examples.
With layout decorators, we can create a rich set of layouts for the pages
of your applications.
A powerful way of using layouts is to build a layout “hierarchy,” where
we start with a base layout at the top that contains what's common
to all pages and add more layouts that contain parts that are used in
subsets of pages. Each additional layout is a decorator, because it uses
another layout higher up in the hierarchy and “decorates” it by adding
more parts.
 
 
 
Search WWH ::




Custom Search