What do we have in this session 8?
Create template client files for the welcome and response pages. Name the template client file for the welcome page greeting.xhtml. For the response page, the file will be response.xhtml.
|
The greeting.xhtml File
|
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets">
<body>
<ui:composition template="./template.xhtml">
<ui:define name="title">
title
</ui:define>
<ui:define name="box">
box
</ui:define>
</ui:composition>
</body>
</html>
The following is the screenshot.
----------------------------------------------------------------------
The template client file references a template using the <ui:composition> tag's template attribute. Because the template contains <ui:insert> tags for title and box, this template client contains <ui:define> tags for these two names. The content that you specify between the <ui:define> tags is what will be inserted into the template between the <ui:insert> tags of the corresponding name.
<ui:define name="title">
Greeting
</ui:define>
Then select the tag from the list of code completion suggestions. The tag library namespace is added to the file's <html> tag (shown in bold below), and the error indicators disappear.
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html">
If you place your cursor after the 'm' in <h:form> and press Ctrl-Space, the namespace is automatically added to the file. If only one logical option is available when pressing Ctrl-Space, it is immediately applied to the file. JSF tag libraries are automatically declared when invoking code completion on tags.