Pular para o conteúdo

Conheça Walt Disney World

JavaServer Faces

JavaServer Faces
20110510-jsf-logo.tiff
Stable release 2.1.11 (Mojarra Reference Implementation) / May 31, 2012; 4 months ago (2012-05-31)
Written in Java
Type Web application framework
Website javaserverfaces.java.net

JavaServer Faces (JSF) is a Java-based web application framework intended to simplify development integration[clarify] of web-based user interfaces.

JSF is a request-driven MVC web framework for constructing user interfaces using components. As a display technology, JSF 2 uses Facelets. Other view technologies such as XUL can also be employed. JSF 1.x uses JavaServer Pages (JSP) for its display technology. JavaServer Faces is a standardized technology which was formalized in a specification through the Java Community Process. It is part of the Java Platform, Enterprise Edition.

Contents

Core features

  • Managed Beans: A dependency injection system (easily interfaced with Seam, CDI, Spring, or Guice) - also called "Backing Beans" or "Page Beans"
  • A template-based[clarify] component system[clarify], for rapid composite component creation - without the need for Java classes.
  • Built-in Ajax support using <f:ajax /> (since JSF v2.0).
  • 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.1 (2010-10-22) — Current version. Second maintenance release of 2.0. Only very minor amount of spec changes.[1][2]
  • JSF 2.0 (2009-06-28) — Major release for ease of use, enhanced functionality, and performance. Coincides with Java EE 6.
  • JSF 1.2 (2006-05-11) — Many improvements to core systems and APIs. Coincides with Java EE 5. Initial adoption into Java EE.

How it Works

Javaserver Faces is based on a 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.

JSF and Ajax

JSF is often used together with Ajax, a Rich Internet application technology. Ajax is a combination of technologies that make it possible to create rich user interfaces. The user interface components in Mojarra (the JSF reference implementation[3]) and Apache 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 frameworks 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 life-cycle conflicts that existed with JSP, forcing workarounds by Java developers.[4] 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, @ManagedProperty and @FacesComponent which 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[clarify] and significantly expanding the standard set of components.

References

Notes

External links

Personal tools
  • Create account
  • Log in
Namespaces

Variants
Actions