Jakarta Faces
JavaServer Faces (JSF) is a Java-based Web application framework intended to simplify development integration of web-based user interfaces.
JSF is a request-driven MVC web framework based on component driven UI design model, using XML files called view templates or Facelets views. Requests are processed by the FacesServlet, which loads the appropriate view template, builds a component tree, processes events, and renders the response (typically HTML) to the client. The state of UI components (and some other objects) is saved at the end of each request (called stateSaving (note: transient true)), and restored upon next creation of that view. Several types of state-saving are available, including Client-side and Server-side state saving. Out of the box, JSF 1.x uses JavaServer Pages (JSP) for its display technology, but can also accommodate other technologies (such as XUL and Facelets). JSF 2 uses Facelets by default for this purpose. Facelets is a more efficient, simple, and yet more powerful view description language (VDL).
Core Features
- Managed Beans: A dependency injection system (easily interfaced with CDI, Spring, or Guice) - also called "Backing Beans" or "Page Beans"
- A templating based component system, for rapid composite component creation - without the need for Java classes.
- Built in Ajax support using <f:ajax /> - no JavaScript required.
- Built in support for bookmarking & page-load actions.
- Integration with the Unified Expression Language (EL), which is core to the function of JSF. Views may access managed bean fields and methods via EL: <my:component rendered="#{myBean.userLoggedIn}" />
- A default set of HTML and web-application specific UI components.
- A server-side event model : For dispatching events and attaching listeners to core system functionality, such as "Before Render Response" or "After Validation"
- State management, supporting: "request", "session", "application", "flash", and "view" scoped Java beans.
- Two XML-based tag libraries (core and html) for expressing a JavaServer Faces interface within a view template (can be used with both JSP or Facelets)
JSF Versions
- JSF 2.0 (2009-06-28) — Current version, major release for ease of use, enhanced functionality, and performance. Coincides with Java EE 6.
- JSF 1.2 (2006-05-11) — (DEPRECATED) many improvements to core systems and APIs
- JSF 1.1 (2004-05-27) — (DEPRECATED) bug fix release. There were no spec or HTML renderkit changes.
- JSF 1.0 (2004-03-11) — (DEPRECATED) the initial release of the JSF specification.
JSF and Ajax
JSF is often mentioned together with Ajax, a Rich Internet application technology. Ajax is a combination of technologies that makes it possible to create rich user interfaces. The user interface components in Mojarra (the JSF reference implementation[1]) and MyFaces were originally developed for HTML only, and Ajax had to be added via JavaScript. This has changed, however:
Because JSF supports multiple output formats, Ajax-enabled components can easily be added to enrich JSF-based user interfaces. The JSF 2.0 specification provides built in support for Ajax by standardizing the Ajax request lifecycle, and providing simple development interfaces to Ajax events, allowing any event triggered by the client to go through proper validation, conversion, and finally method invocation, before returning the result to the browser via an XML DOM update.
JSF 2 includes support for graceful degradation when JavaScript is disabled in the browser.
Popular Extensions and Libraries
- PrettyFaces (Bookmarkable URLs, Url Rewriting, Parameter Injection, Simplified Navigation, and Page-load actions)
- Exadel Fiji (Flex-based Charts and Graphs)
- JSR-299 / Weld Contexts and Dependency Injection for the Java EE Platform (CDI)
- Spring Framework Integration (Dependency Injection Extensions)
Ajax enabled Components and Frameworks
The following companies and projects offer Ajax-based JSF implementations or blueprints or component libraries:
- Apache Trinidad (Robust component library)
- Oracle ADF Faces Rich Client, Oracle Application Development Framework
- Backbase Enterprise Ajax — JSF Edition, Ajax framework
- ICEfaces, open-source, Java JSF extension framework and rich components, Ajax without JavaScript
- jBoss RichFaces and Ajax4jsf, Ajax-enabled JSF Components
- MyFaces, The Apache Foundation JSF Implementation with Ajax Components
- Sun Java BluePrints AJAX Components
- ZK Ajax framework with JSF components
- PrimeFaces - A simple, yet intuitive and powerful component library with a plethora of creative tags.
- OpenFaces Ajax-powered JSF components, an Ajax framework and a client-side validation framework
- Mojarra Scales
Latest Developments
Facelets (which was designed specifically for JavaServer Faces) was adopted as the official view technology for JSF 2.0. This eliminates the well-known life-cycle conflicts that existed with JSP, forcing workarounds by Java developers. Facelets allows easy component/tag creation using XML markup instead of Java code, the chief complaint against JSF 1.x.
The new JSF developments also provide wide accessibility to Java 5 annotations such as @ManagedBean and @ManagedProperty which and removes the need for faces-config.xml in all cases save framework extension. Navigation has been simplified, removing the need for faces-config.xml navigation cases. Page transitions can be invoked simply by passing the name of the desired View/Facelet.
Addition of Partial State Saving and DOM updates are part of the built in standardized Ajax support.
The latest JSF release has built-in support for handling resources like images, CSS and Javascript, allowing artifacts to be included with component libraries, separated into JAR files, or simply co-located into a consistent place within the web-application. Includes logical naming and versioning of resources.
JSF 2.0 also includes a number of other changes like adding support for events, RAILS_ENV style development stages and significantly expanding the standard set of components.
References
- JSF Community - Home Page & Reference
- Sun's JavaServer Faces Technology overview page
- JSF specification
- JSR 314 (JSF 2.0)
- JSR 252 (JSF 1.2)
- JSR 127 (JSF 1.0 and 1.1)
- JSR 316 (Changes to JSF 2.0 in JEE6)
- ^ Ryan Lubke (5 December, 2007). "Project Mojarra - the JSF RI gets a code name".
{{cite web}}
: Check date values in:|date=
(help)
Books
- Jonas Jacobi, John R. Fallows: Pro JSF and Ajax, Apress, ISBN 1-59059-580-7
- Chris Schalk, Ed Burns, James Holmes: JavaServer Faces: The Complete Reference, McGraw-Hill Osborne Media, ISBN 0-07-226240-0
- David Geary, Cay Horstmann: Core JavaServer Faces, Second Edition, Prentice-Hall, 2007 ISBN 0-13-173886-0
- Kito D. Mann: JavaServer Faces in Action, Manning Publications Company, ISBN 1-932394-12-5
- Bill Dudney, Jonathan Lehr, Bill Willis, LeRoy Mattingly: Mastering JavaServer Faces, John Wiley & Sons, ISBN 0-471-46207-1
- Hans Bergsten: JavaServer Faces, O'Reilly & Associates, ISBN 0-596-00539-3
- Budi Kurniawan, Nancy Maragioglio: JavaServer Faces Programming, McGraw-Hill Osborne Media, ISBN 0-07-222983-7
- James Turner, Craig McClanahan, Kunal Mittal: JavaServer Faces Kick Start, SAMS, ISBN 0-672-32599-3
- John Ferguson Smart: JSF Jumpstart - A tutorial introduction to building web sites using JSF, published in electronic form.
External links
- Core Servlets JSF Tutorials Tutorials with Source Code
- JSR 276 Design-Time Metadata for JavaServer Faces Components
- James Holmes' JSF Resources Extensive listing of JSF articles, blog entries, tutorials, and more
- JSF Central JavaServer Faces Community
- JSF Tutorials DevelopIntelligence Community Page
- JSF part of Java EE tutorial
- JSF Tutorials, Examples and Articles catalog
- JSF 2.0 Tutorials Tutorials and code for JSF 2
- JavaServer Faces Home The project page for JSF at java.net
- Apache MyFaces The Apache MyFaces Project, an open-source implementation of JSF under the umbrella of the Apache Software Foundation.
- Oracle resources on Java Server Faces
- JSF, Struts and ZK comparison on Javamagazin(German)
- JSF Matrix listing various JSF implementations and their features
- Component Examples show the use of standard and extended components
- Brief review on the latest changes to JSF 2.0 to be reflected in JEE6