Jump to content

Facelets

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 62.120.149.126 (talk) at 21:26, 4 September 2009. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Facelets
Stable release
1.1.14 / April 15, 2008 (2008-04-15)
Written inJava
Operating systemCross-platform
Size6.31 MB (archived)
TypeWeb Framework
LicenseApache License 2.0
Websitehttp://facelets.dev.java.net/

Facelets, short for JavaServer Faces is an alternative view handler technology for the Java Server Faces (JSF). The framework requires a valid input XML documents to work and is mean that all web pages must be valid XHTML format. Facelets supports all of the JSF UI components and builds its own component tree, reflecting the view for a JSF application. Although both JSP and JSF technologies have been improved to work better together, Facelets eliminates the issues noted in Hans Bergsten's article "Improving JSF by Dumping JSP"[1]

The Facelets project is open source software under the Apache license. Taking from Apache Tapestry's jwcid attribute, Facelets uses jsfc and proper namespaces to convert HTML elements to their associated JSF component.

Facelets are similar to Tiles framework and support templating as well as composition.

As the new development of JavaServer Faces specification version 2.0, Facelets is widely expected to be part of the standard.

Example

The following example shows an XHTML template for taking the use of Facelets component-aliasing. The jsfc attribute is used here, which tags to replace when compiling the page with the corresponding JavaServer Faces components.

<!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 edited with conventional WYSIWYG design tools. This is not possible with regular JSF pages shown bellow the same functionality.

<!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>

References

  1. ^ Hans Bergsten (June 6, 2004). "Improving JSF by Dumping JSP". O'Reilly Media.

Bibliography

See also