June 17, 2017

JSF 2.0 Facelets Tag Libraries

Tag Library

"JSP technology is considered to be a deprecated presentation technology for JavaServer Faces. Facelets is a part of the JavaServer Faces specification and also the preferred presentation technology for building JavaServer Faces technology-based applications."

Tag Library URI Prefix Example Contents
JavaServer Faces HTML Tag Library http://java.sun.com/jsf/html h: h:head
h:body
h:outputText
h:inputText
JavaServer Faces component tags for all UIComponent objects
JavaServer Faces Core Tag Library http://java.sun.com/jsf/core f: f:actionListener
f:attribute
Tags for JavaServer Faces custom actions that are independent of any particular render kit
JavaServer Faces Facelets Tag Library http://java.sun.com/jsf/facelets ui: ui:component
ui:insert
Tags for templating
JSTL Core Tag Library http://java.sun.com/jsp/jstl/core c: c:forEach
c:catch
JSTL 1.2 Core Tags
JSTL Functions Tag Library http://java.sun.com/jsp/jstl/functions fn: fn:toUpperCase
fn:toLowerCase
JSTL 1.2 Functions Tags

Reference: Oracle Java EE 6 Tutorial: What Is Facelets?

Facelet Template

<?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://java.sun.com/jsf/html"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:ui="http://java.sun.com/jsf/facelets"
 xmlns:c="http://java.sun.com/jsp/jstl/core"
 xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<h:head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 <h:outputStylesheet library="css" name="default.css" />
 <title>Facelets Template</title>
</h:head>
<h:body>

 <h1>Hello</h1>

</h:body>
</html>

No comments: