Java Reference
In-Depth Information
Listing 6-16. contents.xhtml
1. <?xml version="1.0" encoding="UTF-8"?>
2. <html xmlns=" http://www.w3.org/1999/xhtml "
3. xmlns:ui=" http://java.sun.com/jsf/facelets ">
4. <body>
5. <ui:composition>
6. <h1>Book Store Home</h1>
7. </ui:composition>
8. </body>
9. </html>
Line 5 : The ui:composition tag indicates to the Facelets system that the
enclosing children should be grafted into the UIComponent hierarchy at the point
where contents.xhtml is inserted.
Listing 6-17 illustrates the home.xhtml file that defines content.xhtm .
Listing 6-17. home.xhtml
1. <?xml version="1.0" encoding="UTF-8"?>
2. <!DOCTYPE html>
3. <html xmlns=" http://www.w3.org/1999/xhtml "
4. xmlns:h=" http://java.sun.com/jsf/html "
5. xmlns:ui=" http://java.sun.com/jsf/facelets ">
6. <h:body>
7. <ui:composition template="templates/common.xhtml">
8. <ui:define name="content">
9. <ui:include src="/contents.xhtml" />
10. </ui:define>
11. </ui:composition>
12. </h:body>
13. </html>
Line 7 : The ui:composition tag declares the template common.xhtml to which
the enclosed content contents.xhtml should be applied using the template
attribute.
You can now run this application using the URL http://localhost:8080/JSFTemplate/home.faces ,
as shown in Figure 6-17 .
 
Search WWH ::




Custom Search