Basic Syntax

Templates must be valid XML.

Tag libraries are referenced by XML namespaces. The namespace declaration may appear on any enclosing element.

Built-in Tag Libraries

UI library

A subset of Facelet's UI library is supported with the namespace xmlns:ui="http://sarugo.org/xtc/ui".

ui:include

Simple include mechanism. The whole of the referenced template is included. Parameters may be passed using ui:param.

Attributes

AttributeRequiredDefaultDescription
srcYesNoneURL or relative path to template to include.

Sub-elements

Only ui:param is permitted, all other elements will be stripped from the output.

Example

<ui:include src="../menu.xhtml"/>

ui:composition

Defines a composition, that is a collection of elements for reuse. Additionally supports templating through the ui:define and ui:insert elements. A composition excludes all elements not within the composition from the output.

Attributes

AttributeRequiredDefaultDescription
templateNoNoneURL or relative path to template to use.

Sub-elements

Any are permitted. If a template is provided, ui:define can be used to provide named fragments (element-trees) to the template. Additionally, ui:param can be used to define variables for use by the template. When templating, any sub-elements which are not part of a ui:define are passed as the unnamed fragment (see ui:insert).

Example

template.xhtml:

<html>
<body>
<h1>#{heading}</h1>
<div class="body"><ui:insert/></div>
<div class="footer"><ui:insert name="footer">Default Footer</ui:insert></div>
</body>
</html>

composition.xhtml:

<html>
<body>
All this will be removed.
<ui:composition template="template.xhtml">
<ui:param name="heading" value="This is the Heading"/>
<ui:define name="footer">Footer with <b>boldness</b>.</ui:define>
<p>This will be the body.</p>
</ui:composition>
This too will be removed.
</body>
</html>

ui:decorate

Similar to ui:include, however this tag supports ui:define as per ui:composition. Typically used with a composition which defines a reusable fragment.

Attributes

AttributeRequiredDefaultDescription
templateYesNoneURL or relative path to template to use.

Sub-elements

Any are permitted. ui:define can be used to provide named fragments (element-trees) to the template. Additionally, ui:param can be used to define variables for use by the template. Any sub-elements which are not part of a ui:define are passed as the unnamed fragment (see ui:insert).

Example

listitem.xhtml:

<html>
<body>
All this will be removed.
<dl>
<ui:composition><dt>#{term}</dt><dd><ui:insert name="definition"/></dd></ui:composition>
</dl>
This too will be removed.
</body>
</html>

page.xhtml:

<html>
<body>
<h1>A list of terms</h1>
<dl>
<ui:decorate template="listitem.xhtml">
<ui:param name="term" value="foo"/>
<ui:define name="definition"><b>Not</b> a <i>bar</i>.</ui:define>
</ui:decorate>
</dl>
</body>
</html>

ui:define

Defines a fragment for use by a template. Only supported as a sub-element to ui:composition and ui:decorate.

Attributes

AttributeRequiredDefaultDescription
nameNoNoneName of the fragment. Must be unique within the parent element.

Sub-elements

Any or none are permitted. All sub-elements are associated with the given name (or the unnamed fragment if no name is given).

ui:insert

Inserts a fragment defined by ui:define when being rendered as a template by ui:composition or ui:decorate.

Attributes

AttributeRequiredDefaultDescription
nameNoNoneName of the fragment.

Sub-elements

Any are permitted and provide a default value for the fragment. If the named fragment was not defined by the calling ui:composition or ui:decorate, then the sub-elements are output; otherwise, the will be omitted from the output.

ui:param

Defines a variable for the template invoked by ui:include, ui:composition or ui:decorate. The variable is only in scope for the invoked template (and not the current template).

Attributes

AttributeRequiredDefaultDescription
nameYesNoneName of the variable to define.
valueYesNoneThe value the variable should take.

Sub-elements

None permitted, any will be ignored.

ui:repeat

Provides a simplified implementation of c:forEach for iterating over an array, map or collection.

Attributes

AttributeRequiredDefaultDescription
valueYesNoneAn array, map or collection (or null) to iterate over.
varYesNoneName of the variable to define for each element in the value.

Sub-elements

Any elements are permitted. For each element in the value (if any), any sub-elements are repeated. The variable named per the var attribute will be available to sub-elements.

Example

<table>
<ui:repeat value="#{books}" var="book">
<tr><td>#{book.title}</td><td>#{book.author}</td></tr>
</ui:repeat>
</table>

JSTL core library

A subset of the JSTL 1.1 core library is supported with the namespace xmlns:c="http://java.sun.com/jsp/jstl/core":

JSTL formatting library

A subset of the JSTL 1.1 formatting library is supported with the namespace xmlns:fmt="http://java.sun.com/jsp/jstl/fmt":

JSTL function library

The JSTL 1.1 function library is supported with the namespace xmlns:fn="http://java.sun.com/jsp/jstl/functions":

  • fn:contains
  • fn:containsIgnoreCase
  • fn:endsWith
  • fn:escapeXml
  • fn:indexOf
  • fn:join
  • fn:length
  • fn:replace
  • fn:split
  • fn:startsWith
  • fn:substring
  • fn:substringAfter
  • fn:substringBefore
  • fn:toLowerCase
  • fn:toUpperCase
  • fn:trim

JSF core library

A subset of the JSF 1.1 core library is supported with the namespace xmlns:f="http://java.sun.com/jsf/core":

Custom Tag Libraries

TBD - for now see Facelet's documentation and remember the Differences To Facelets.