SiteMesh - SiteMesh Tag Reference

SiteMesh is bundled with 2 tag-libraries.

For installation instructions, see Installation and Configuration, and for usage instructions and examples see Building Decorators.

Note that the tags below are listed without the namespace prefixes as these are defined by the user when importing the tag library into the JSP page.

Decorator Tags Page Tags
Used to create decorator pages. Used to access decorators from content pages.
<decorator:head />
<decorator:body />
<decorator:title />
<decorator:getProperty />
<decorator:usePage />
<page:applyDecorator />
<page:param />

Decorator Tags

These tags are used to create page Decorators. A Decorator is typically built up from an HTML layout (or whatever is appropriate for the original page content-type) with these tags inserted to provide place-holders for the data from the original (undecorated) page.

For more details, see Building Decorators.

<decorator:head />

Description:

Insert contents of original page's HTML <head> tag. The enclosing tag will not be be written, but its contents will.

Attributes:

  • None

<decorator:body />

Description:

Insert contents of original page's HTML <body> tag. The enclosing tag will not be be written, but its contents will.

Note: the content of the body onload and onunload events (and other body attributes) can be included in the decorator by getting the property body.onload and body.onunload (the named attributes).
For example (the decorator): <body onload="<decorator:getProperty property="body.onload" />">

For more information: see getProperty.

Attributes:

  • None

<decorator:title [ default="..." ] />

Description:

Insert title of original page (obtained from <title> tag). will be used instead.

Attributes:

  • default (optional)
    Value to be inserted if title not found.

<decorator:getProperty property="..." [ default="..." ] [ writeEntireProperty="..." ]/>

Description:

Insert property of original page. See API reference for HTMLPage for details of how properties are obtained from a page.

Attributes:

  • property (required)
    Name (key) of property to insert.

  • default (optional)
    Value to be inserted if property not found.

  • writeEntireProperty (optional)
    This writes the property with a space in front including the name ( propertyName="propertyValue")
    Accepted values are true, yes and 1.
    For example:
    The decorator: <body bgcolor="White"<decorator:getProperty property="body.onload" writeEntireProperty="true" />>
    The undecorated page: <body onload="document.someform.somefield.focus();">
    The decorated page: <body bgcolor="White" onload="document.someform.somefield.focus();">

<decorator:usePage id="..." />

Description:

Expose the Page object as a variable to the decorator JSP.

Attributes:

  • id (required)
    Name of variable to assign to.

Example:

<decorator:usePage id="myPage" />
<% if ( myPage.getIntProperty("rating") == 10 ) { %>
  <b>10 out of 10!</b>
<% } %>

Page Tags

The page tags, are used to apply decorators to inline or external content from within the current page.

<page:applyDecorator name="..." [ page="..." title="..." ] >
   .....
</page:applyDecorator>

Description:

Apply a Decorator to specified content. The content can either be inline by specifying a body to the tag, or by using the result of another page by specifying the page attribute.

Attributes:

  • name (required)
    Name of the Decorator to apply to the included page.

  • page (optional)
    Points to the external resource which should expose an entire page (e.g. another JSP file producing a valid page). This attribute can be relative to the page it is being called from, or an absolute path from the context-root.

  • title (optional)
    Override the title of the page available as Page.getTitle() or <decorator:title/> from within the Decorator. This is identical to specifying <page:param name="title">...<page:param>.

Body:

The content to have the Decorator applied to.

<page:param name="..."> ... </page:param>

Description:

Pass a parameter to a Decorator. This will override the value called from Page.getProperty() or <decorator:getProperty/>. This tag is only valid inside a <page:applyDecorator> tag.

Attributes:

  • name (required)
    The name of the parameter to override.

Body:

The value of the parameter.