Learn Java for Web Development

(Tina Meador) #1
CHAPTER 6: Component-Based Web Development Using JSF 2 287

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. Book Store Home













   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">


























   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.

Free download pdf