Java Reference
In-Depth Information
Developing the user interface
Before developing the WebSocket-specific code, let's develop the user interface
using JSF 2.2 and HTML5-friendly markup as explained in Chapter 2 , Developing
Web Applications Using JavaServer Faces 2.2 .
When adding JSF as a framework to a NetBeans project, an index.xhtml ile is
automatically generated. Take a look at the following code:
<?xml version='1.0' encoding='UTF-8' ?>
<!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:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
Hello from Facelets
</h:body>
</html>
The generated markup uses JSF-specific tags. We need to make a few small changes
to modify it to use HTML5-friendly markup. Take a look at the following code:
<?xml version='1.0' encoding='UTF-8' ?>
<!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:jsf="http://xmlns.jcp.org/jsf">
<head jsf:id="head">
<title>Facelet Title</title>
<head>
<body jsf:id="body">
Hello from Facelets
</body>
</html>
The main change we made was to replace the xmlns:h=http://xmlns.jcp.org/jsf/
html namespace with xhmlns:jsf=http://xmlns.jsp.org/jsf ; the former specifies
JSF-specific tags (that we won't use in our application), while the latter specifies
JSF-specific attributes (that we will use in our applications). Then, we changed
the JSF-specific <h:head> and <h:body> attributes with their standard HTML
counterparts, and we added the JSF-specific jsf:id attribute to both tags. Recall
from Chapter 2 , Developing Web Applications Using JavaServer Faces 2.2 , that to make JSF
interpret HTML tags, we need to add at least one JSF-specific attribute to the tags.
 
Search WWH ::




Custom Search