First, let's talk about the <ui:decorate>
tag. As its name suggests, this tag is used for decorating pieces of a page. Unlike <ui:composition>
, this tag doesn't ignore the content that is not enclosed in it, which may be an added advantage sometimes. Well, a simple example is shown in the following code (the template
attribute is mandatory):
<?xml version='1.0' encoding='UTF-8' ?> <!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://xmlns.jcp.org/jsf/html" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> <h:head> <title></title> </h:head> <h:body> <h:outputText value="You can see this header text thanks to ui:decorate!"/> <ui:decorate template="template/layout.xhtml"> <ui:define name="content">...