JavaServer Faces
From Wikipedia, the free encyclopedia
JavaServer Faces (JSF) is a Java-based Web application framework that simplifies the development of user interfaces for Java EE applications. Out of the box, JSF uses JavaServer Pages for its display technology, but JSF can also accommodate other display technologies (such as XUL). JSF includes:
- A set of APIs for representing user interface (UI) components and managing their state, handling events and input validation, defining page navigation, and supporting internationalization and accessibility
- A default set of UI components
- Two JavaServer Pages (JSP) custom tag libraries for expressing a JavaServer Faces interface within a JSP page.
- A server-side event model
- State management
- Managed Beans (JavaBeans created with dependency injection)
- Unified Expression Language for both JSP 2.0 and JSF 1.2
The JSF specification was developed under the Java Community Process as JSR 127, which defined JSF 1.0 and 1.1, and JSR 252 which defined JSF 1.2.
Contents |
[edit] JSF versions
- JSF 1.0 (2004-03-11) - the initial release of JSF specification.
- JSF 1.1 (2004-05-27) - bug fix release. There were no spec or HTML renderkit changes.
- JSF 1.2 (2006-05-11) - latest release.
- enhancements to provide an interim solution to the content-interweaving problem described at http://www.onjava.com/pub/a/onjava/2004/06/09/jsf.html
- provide XML Schema for the config files, instead of using DTD
- enhancements to allow faces applications to handle multi-frame, or multi-window UI designs
- enhancements to the f: tag library for improved TCK coverage, f:view lifetime events, and other small features
- enhancements to the decorator support for API objects
- security enhancements for client side state saving
- solve the "duplicate button press" problem
- re-organize the spec into normative, and non-normative sections, to make implementation easier
- portlet related bug-fixes
- bug fixes that require minimal specification changes
[edit] Comparison to other Web-GUI Frameworks
[edit] Microsoft ASP.NET
ASP.NET from Microsoft features a component based approach to WebApplication development similar to JSF. In ASP.Net v1, component rendering code was bundled with the UI component, unlike JSF, where rendering and component interfaces can be separated, thus allowing for customization of the renderer. ASP.Net v2 introduced the control adapter framework allowing the default rendering to be overridden by 3rd party code. ASP.NET is also more tightly integrated into the Microsoft development tools, thereby enabling Drag & Drop UI generation in Visual Studio.
Business code is connected to the UI components by subscribing to events generated by the components and stored in a separate file ("code behind"). Thus a typical ASP.NET page consists of a (HTML) file describing the visual page layout (design), and a file with the page logic (code). Both files are treated as one single entity by the Microsoft development tools.
As a consequence, presentation layer and business logic is normally tightly coupled in ASP.NET applications (in Java technology often referred to as Model 1). This is a major difference to JSF or Struts, where business logic is by design much more segregated from the presentation layer via a strict MVC paradigm and a separate definition of page flow (Model 2). Implementation of the latter is also possible by use of certain frameworks.
[edit] WebObjects / Wotonomy
WebObjects is the earliest known web-application framework and was originally developed by NeXT Software, Inc. then acquired by Apple Computer when it acquired NeXT. It contains an MVC architecture with a similar component and event model, and lifecycle to JSF. It is deployable without J2EE (its original configuration), or can be deployed in a servlet container, its dispatcher object acting as the entry-point of a J2EE webapp. Unlike JSF's default case, components are not defined in JSP files, but are in .woc directories containing (any or all of) an html/xml/wml template file, a file to map fields and actions to java code, and a .java class. The template file provides the rendering/layout and may include other WebObjects components, rather than the delegated RenderKit approach used by default in JSF. It is a halfway-point between the delegated and directly-rendered approaches used in JSF.
WebObjects also includes a layered architecture with one of the earliest Object-Relational Mapping frameworks, Enterprise Objects Framework.
Wotonomy is a clean-room, open-source re-implementation of the WebObjects frameworks licensed under LGPL. It attempts to implement all parts of WebObjects, and has implemented the whole MVC web-GUI stack. As a clone of WebObjects, it differs from JSF in identical ways, except where it is incomplete.
[edit] Apache Tapestry
Tapestry is an open-source framework for creating dynamic, robust, scalable web applications in Java. Tapestry builds upon the standard Java Servlet API, and so it works in any servlet container or application server. Unlike JSF, Tapestry does not use JSP as the view technology - instead preferring an alternate templating engine that allows for easy html preview and editing.
[edit] Struts
Struts is a popular Model 2 MVC framework from the Apache Software Foundation. It provides page-at-a-time MVC and does not have a component-model in the style of JSF. Pages are mapped to models with a dispatch servlet (controller) piping input to actions. In Struts, unlike the component-oriented approaches above where components consume their own form data, a struts action is responsible for knowing and digesting the parameters of the request. Struts applications use JSPs to render views and are amenable to mix-and-match jsp taglib use. (See also Apache Beehive)
[edit] See also
[edit] References
- JSF home page
- JSF specification
- JSR 252 (JSF 1.2)
- JSR 127 (JSF 1.0 and 1.1)
[edit] 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, Prentice-Hall, ISBN 0-13-146305-5
- 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
[edit] External links
- Core Servlets Tutorials Core Servlets Tutorials Page
- 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 FAQ a large FAQ about Java Server Faces
- JSF part of Java EE tutorial
- JSF Tutorials, Examples and Articles catalog
- 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.