Software:JavaServer Faces
File:20110510-jsf-logo.tiff | |
Stable release | 2.3.9 (Mojarra Reference Implementation)
/ November 30, 2018 |
---|---|
Preview release | 2.4.0 SNAPSHOT (Mojarra Reference Implementation)
/ March 28, 2017 |
Written in | Java |
Type | Web application framework |
Website | javaee |
JavaServer Faces (JSF) is a Java specification for building component-based user interfaces for web applications[1] and was formalized as a standard through the Java Community Process being part of the Java Platform, Enterprise Edition. It is also a MVC web framework that simplifies construction of user interfaces (UI) for server-based applications by using reusable UI components in a page.[2]
JSF 2 uses Facelets as its default templating system. Other view technologies such as XUL or plain Java[3] can also be employed. In contrast, JSF 1.x uses JavaServer Pages (JSP) as its default templating system.
History
In 2001, the original Java Specification Request (JSR) for the technology that ultimately became JavaServer Faces proposed developing a package with the name javax.servlet.ui
[4]
By June 2001, JavaWorld would report on Amy Fowler's team's design of "the JavaServer Faces API" (aka "Moonwalk") – "an application framework for creating Web-based user interfaces".[5]
Versions
- JSF 2.3 (2017-03-28) – Major features: search Expressions, extensionless URLs, bean validation for complete classes, push communication using WebSocket, enhanced integration with CDI.[6]
- JSF 2.2 (2013-05-21) – Introduced new concepts like stateless views, page flow and the ability to create portable resource contracts.[7]
- JSF 2.1 (2010-11-22) – Maintenance release 2 of JSF 2.0. Only a very minor number of specification changes.[8][9]
- JSF 2.0 (2009-07-01) – 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.
- JSF 1.1 (2004-05-27) – Bug-fix release. No specification changes.
- JSF 1.0 (2004-03-11) – Initial specification released.
How it works
Based on a component-driven UI design-model, JavaServer Faces uses XML files called view templates or Facelets views. The FacesServlet
processes requests, loads the appropriate view template, builds a component tree, processes events, and renders the response (typically in the HTML language) to the client. The state of UI components and other objects of scope interest is saved at the end of each request in a process called stateSaving (note: transient true), and restored upon next creation of that view. Either the client or the server side can save objects and states.
JSF and Ajax
JSF is often used together with Ajax, a Rich Internet application development technique. Ajax is a combination of web development techniques and technologies that make it possible to create rich user interfaces. The user interface components in Mojarra (the JSF reference implementation[10]) 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:
- Apache MyFaces – The Apache Foundation JSF implementation with Ajax components
- Backbase Enterprise Ajax – JSF Edition – Ajax framework
- BootsFaces Open source JSF Framework based on Bootstrap
- IBM Notes – XPages
- ICEfaces – open-source, Java JSF extension framework and rich components, Ajax without JavaScript
- JBoss RichFaces (derived from and replaces Ajax4jsf) – Ajax-enabled JSF components for layout, file upload, forms, inputs and many other features. It reached its end-of-life in June 2016.
- OmniFaces – open-source JSF utility library
- Open Faces – Ajax framework with JSF components
- Oracle ADF Faces Rich Client – Oracle Application Development Framework
- PrimeFaces – Ajax framework with JSF components
- Sun Java BluePrints AJAX components
- ZK – Ajax framework with JSF components
Latest developments
Facelets (that 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.[11] 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
that removes the need for faces-config.xml
in all cases except 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. This includes logical naming and versioning of resources.
JSF 2.0 also includes a number of other changes like adding support for events, separate development, staging, and production modes, similar to RAILS_ENV
in Ruby on Rails, and significantly expanding the standard set of components.
Criticisms
In their January 2014 "Technology Radar" publication, ThoughtWorks wrote:[12]
We continue to see teams run into trouble using JSF -- JavaServer Faces -- and are recommending you avoid this technology. Teams seem to choose JSF because it is a JEE standard without really evaluating whether the programming model suits them. We think JSF is flawed because it tries to abstract away HTML, CSS and HTTP, exactly the reverse of what modern web frameworks do. JSF, like ASP.NET webforms, attempts to create statefulness on top of the stateless protocol HTTP and ends up causing a whole host of problems involving shared server-side state. We are aware of the improvements in JSF 2.0, but think the model is fundamentally broken. We recommend teams use simple frameworks and embrace and understand web technologies including HTTP, HTML and CSS.
In the article published November 2014 in the DZone website, titled "Why You Should Avoid JSF", Jens Schauder wrote:[13]
Facelets, the preferred presentation technology of JSF looks at first sight like an ordinary templating technology like the good old JSP or Thymeleaf. But if you look closer the horror becomes obvious. In the same place where you structure your HTML, you also place the logic what parts of the UI should get updated on an action. A clear violation of the separation of concerns principle in my book. Even better is the immediate attribute which changes the server side life cycle! And if this isn’t enough it does it in different ways depending on what tag you use it on. You can’t make stuff like this up.
Rebuttal to criticisms
In February 2014, Çağatay Çivici (PrimeFaces Lead) responded to ThoughtWorks criticisms in a post titled: JSF is not what you’ve been told anymore. Çivici argues that improvements in JSF over the years offer many features that embrace modern web development, providing the option to write your own JavaScript, HTML, and CSS. Also regarding state, Çağatay wrote:
JSF is a stateful framework by nature and state makes web applications easy to develop with. With improved state management techniques introduced in JSF 2.0+ (e.g. stateless mode, partial state saving), JSF can scale as well.
References
- ↑ JavaServer Faces Technology
- ↑ "JSF 2.0 Tutorial". mkyong. 2010-12-12. http://www.mkyong.com/tutorials/jsf-2-0-tutorials/. Retrieved 2017-04-28. "JavaServer Faces (JSF) 2.0, is an MVC web framework which focus on simplifies building user interfaces (comes with 100+ ready UI tags) for Java web application and make reusable UI component easy to implement."
- ↑ NoVDL: Write your JSF views in pure Java
- ↑ "JSR 127: JavaServer Faces". Oracle Corporation. 2014. https://www.jcp.org/en/jsr/detail?id=127. Retrieved 2014-08-05. "2.6 Is there a proposed package name for the API Specification? (i.e., javapi.something, org.something, etc.) [:] javax.servlet.ui"
- ↑ Armstrong, Eric (2001-06-06). "Java Web services: What's not to like?: Java offers end-to-end, top-to-bottom, client/server solutions". JavaWorld (JavaWorld, Inc.). http://www.javaworld.com/article/2075969/core-java/java-web-services--what-s-not-to-like-.html. Retrieved 2014-08-08. "The JavaServer Faces API (aka Moonwalk) promises to provide an elegant solution for implementing interactive functionality on incompatible browsers. […] Designed by a team led by Amy Fowler, Sun's AWT and Swing architect, the JavaServer Faces API will provide a collection of GUI tools that will run on common browsers using standard HTML."
- ↑ Tijms, Arjan. "What's new in JSF 2.3?". http://arjan-tijms.omnifaces.org/p/jsf-23.html. Retrieved 23 March 2016.
- ↑ JSF 2.2 (JSR-344) is final | techscouting through the java news. Blog.oio.de. Retrieved on 2013-07-29.
- ↑ JSR 314 JavaServer Faces 2.1 JSF 2.1 | techscouting through the java news. Blog.oio.de. Retrieved on 2013-07-29.
- ↑ Bosch, Andy (2010-11-29). "Was ist neu in JSF 2.1" (in German). it-republik.de. http://it-republik.de/jaxenter/news/Was-ist-neu-in-JSF-2.1-057653.html. Retrieved 2013-02-19.
- ↑ Ryan Lubke (5 December 2007). "Project Mojarra - the JSF RI gets a code name". https://blogs.oracle.com/rlubke/entry/project_mojarra_the_jsf_ri.
- ↑ Bergsten, Hans. "Improving JSF by dumping JSP". O'Reilly. http://onjava.com/pub/a/onjava/2004/06/09/jsf.html. Retrieved 18 August 2011.
- ↑ "Technology Radar". ThoughtWorks. January 2014. p. 12. http://thoughtworks.fileburst.com/assets/technology-radar-jan-2014-en.pdf.
- ↑ Jens Schauder (November 2014). "Why You Should Avoid JSF". DZone. https://dzone.com/articles/why-you-should-avoid-jsf.
External links