In the previous example, we saw that content from one page could be included in another page by using a combination of the<ui:include>
and<ui:composition>
tags. Let's discuss the<ui:composition>
tag in more detail.
When Facelets encounters a<ui:composition>
tag, it includes the surrounded content and "trims" the content outside this tag. The surrounded content is included as is, and unlike the<ui:component>
tag, is not wrapped in a UI component.
The following source code example demonstrates how to include a Facelets UI composition using the<ui:include>
tag. When the markup in the file named composition.jsf
is included, only the content inside the<ui:composition>
tag is rendered.
<!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:ui=http://java.sun.com/jsf/facelets> ...