Facelets

from Wikipedia, the free encyclopedia
Facelets
Basic data

developer java.net
Current  version 1.1.15
(November 24, 2009)
operating system cross-platform
programming language Java
category Web framework , Java
License Apache license
facelets.java.net

Facelets is a free template system and the standard technology JavaServer Faces (JSF). It replaces JavaServer Pages for defining the views. Facelets requires valid XML documents as input . Therefore the pages are created in XHTML format.

An important feature of facelets is what is known as component aliasing . This makes it possible to use normal HTML tags such as <input> instead of the tags for the UI components . The connection to the UI component is established via the alias attribute jsfc in the tag. The corresponding component is inserted by facelets when the page is compiled. The advantage of component aliasing is that web designers can edit the page with conventional HTML editors , since normal HTML tags are used. The additional attributes for JSF do not interfere with this.

Facelets offers a wide range of options for combining template fragments to form a complete page - for example, to create a uniform header on every page. Another advantage of Facelets over JavaServer Pages is that expressions in the Expression Language can be placed outside of tags in the page source text.

The dependency on XHTML may change. U. also represent a disadvantage. When using facelets you have to be aware that the original markup independence of JSF is lost and alternative renderers of the JSF components ( Telnet etc.) can no longer be used in connection with facelets.

The Facelets project is free software under the Apache license . The project managers are Jacob Hookom and Roger Kitain, who were involved in version 1.2 of the JavaServer-Faces specification in Java Specification Request 252 .

As part of the development of the JavaServer-Faces specification version 2.0 in Java Specification Request 314, Facelets was integrated into the standard specification as the preferred VDL (View Declaration Language).

example

The following example shows an XHTML template for facelets using component-aliasing . The jsfc attribute is used to replace the tags when the page is compiled by the corresponding JavaServer Faces components. A form with a text input field and a button for submitting the form is generated. In addition, logged-in users are welcomed (to demonstrate the Unified Expression Language).

<!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">
 <body>
  <form jsfc="h:form">
   <span jsfc="h:outputText" value="Willkommen #{loggedInUser.name}" disabled="#{empty loggedInUser}" />
   <input type="text" jsfc="h:inputText" value="#{bean.property}" />
   <input type="submit" jsfc="h:commandButton" value="OK" action="#{bean.doSomething}" />
  </form>
 </body>
</html>

The above code can be viewed in a browser and manipulated with an HTML designer. This is not possible with classic JSF pages; the browser would use JSF elements such as B. h: output cannot be displayed:

<!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">
 <body>
  <h:form>
   <h:outputText value="Willkommen #{loggedInUser.name}" disabled="#{empty loggedInUser}" />
   <h:inputText value="#{bean.property}" />
   <h:commandButton value="OK" action="#{bean.doSomething}" />
  </h:form>
 </body>
</html>

Web links

Individual evidence

  1. Java Specification Request 252
  2. Java Specification Request 314