Jump to content

Jakarta Faces

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Timonczesq (talk | contribs) at 20:48, 26 January 2010 (Deleted a link. Not only was it a 3rd-party site's advertisement, but also was placed randomly and totally out of context.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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.

Ajax enabled Components and Frameworks

The following companies and projects offer Ajax-based JSF implementations or blueprints or component libraries:

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

  1. ^ Ryan Lubke (5 December, 2007). "Project Mojarra - the JSF RI gets a code name". {{cite web}}: Check date values in: |date= (help)

Books