Developing Web 2.0 applications
with JavaServerFaces
and Dreamweaver
>> Just Became Easier
Documentation
Search
  1. Introduction
  2. Getting Started
  3. Facelets Concepts
  4. Document Types
  5. Design View
  6. Code View Support
  7. Keyboard Shortcuts
  8. Tag Object Toolbars
  9. Property Inspectors
  10. Facelets Tag Reference
Facelets UI Tag Library
  ui:component
  ui:composition
  ui:debug
Selected ui:decorate
  ui:define
  ui:fragment
  ui:include
  ui:insert
  ui:param
  ui:remove
  ui:repeat
If you like this documentation, please take a look at my book:

10. Facelets UI Tag Reference

Documentation > Facelets > Facelets Tag Reference > Facelets UI Tag Library > ui:decorate

ui:decorate

The UI Decorate tag is a templating tag that decorates content included from another Facelet. Any content outside of the UI Decorate tag will be displayed by the Facelets view handler. Any content within the decorate tag will be passed to the associated template as parameters or simply ignored. You can use nested ui:define tags to pass named content to the associated template. See ui:insert for more information.

Templating Tip:

The content of the page containing the decorate tag is be used to populate an associated template page. If the decorate tag contains ui:define tags, the content of these tags will be inserted into the template where matching ui:insert tags can be found. You can use a nameless ui:insert tag to insert all the content of the composition tag within the template page.

decorate.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head />
<body>
<h:form>
	Text before will stay.
	<ui:decorate template="decorate-template.xhtml">
		<ui:define name="title">Our Products</ui:define>
		<ui:define name="body">
			<ul>
				<li>Apples</li>
				<li>Oranges</li>
				<li>Bananas</li>
			</ul>
		</ui:define>
	</ui:decorate>
	Text after will stay.
</h:form>
</body>
</html>
This example was formatted by JSFToolbox for Dreamweaver.

decorate-template.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head />
<body>
<h:form>
	This text will be removed.
	<ui:composition>
		<h2>
			<ui:insert name="title" />
		</h2>
		<ui:insert name="body" />
	</ui:composition>
	This text will be removed.
</h:form>
</body>
</html>
This example was formatted by JSFToolbox for Dreamweaver.

Rendered Output

Rendered ui:decorate tag

HTML Output

Text before will stay.
<h2>Our Products</h2>
<ul>
  <li>Apples</li>
  <li>Oranges</li>
  <li>Bananas</li>
</ul>
Text after will stay.

Tag Attributes

template File
 
A URI that points to a template, also known as a layout, that inserts pieces of the page defined in the decorator.