Facelets

From Seo Wiki - Search Engine Optimization and Programming Languages

Jump to: navigation, search

Facelets is an open source web framework under the Apache license and alternative view handler technology for the JavaServer Faces (JSF). The framework requires a valid input XML documents to work. This means 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]

Facelets is similar enough to Apache Tapestry to draw comparison. In fact, Tapestry was well ahead of its time when it first came out, and Facelets does draw on some of its ideas. The project conceptually similar to Tapestry's which use jwcid attribute and Facelets uses jsfc and proper namespaces to convert HTML elements to their associated JSF component. Also, there are some similarity to Tiles framework and support templating as well as composition.

As the next development of JavaServer Faces 2.0, the specification is widely influenced by Facelets and expected to be part of the standard JSR 314.

Contents

Example

The following example shows an XHTML template for taking the use of Facelets component-aliasing. The jsfc attribute is used here, shows 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="Welcome, #{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 1.2 pages (shown below 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="Welcome, #{loggedInUser.name}" disabled="#{empty loggedInUser}" />
   <h:inputText value="#{bean.property}" />
   <h:commandButton value="OK" action="#{bean.doSomething}" /> 
  </h:form>
 </body>
</html>

References

Bibliography

See also

External links

Personal tools

Served in 0.220 secs.