# JSF Templating - Developer Documentation ## JSF Templating JavaServer Faces (JSF) offers a powerful templating system that promotes code reuse and modularity. It uses Facelets as its default templating system, allowing developers to leverage HTML-like templates in their applications. ## JSF Template A JSF template, often saved with an `.xhtml` extension, serves as a blueprint for web pages, defining their basic layout and structure. The typical JSF template includes placeholders for content that will be defined later. Here's a simple example of a JSF template: `` `` `` `` `` In this template, `` acts as a placeholder for dynamic content. ## JSF Template Client A JSF template client is a web page that uses a template for its layout. It fulfills the placeholders defined in the template with actual content. ### HTML / Composition Difference In JSF, there are two important tags: `html` and `ui:composition`. - `` tag: This is the root tag for an HTML document. - `` tag: This Facelets tag defines a template client page. It may optionally reference a template file (`template` attribute) and can contain `` tags to provide content for placeholders. ### Linking Template to Client To link a template to a client page, you use the `` tag with a `template` attribute. The `template` attribute's value should be the path to the template file. Example: ```xhtml ``` ## ui:define `` is a Facelets tag used in a template client to provide content for placeholders (`` tags) in the template. The `name` attribute should match the name specified in the `` tag of the template. Example: ```xhtml

Welcome to our website!

``` ## ui:insert `` is a Facelets tag used in a template to define a placeholder for content. The `name` attribute identifies the placeholder. A template client can then fill these placeholders with actual content using `` tags. Example: ```xhtml ``` In a template client: ```xhtml ``` Remember, JSF templating system is about building reusable and maintainable UI components and layouts. By mastering ``, ``, and ``, you can construct powerful, dynamic web pages.