News Stay informed about the latest enterprise technology news and product updates.

JavaServer Faces preps for new version, HTML5, mobile explosion

Despite predictions that Oracle would allow JavaServer Faces to languish, Java experts say JSF is alive and well, and poised to complement HTML5 and JavaScript.

When Oracle Corp. bought Sun Microsystems Inc. and took Java under its wing, some thought that JavaServer Faces (JSF) would go the way of Latin and Sanskrit. Contrary to those predictions, however, Oracle’s focus on enterprise didn’t shove JSF into the background in favor of other technologies. Instead, Oracle continues to promote JSF as a way to handle front-end development.

Java developers and experts say JSF is alive and well, and poised to complement HTML5 and JavaScript – and, in some cases, replace Adobe Flash.

 “In April 2011, we started work on the next major revision of the JSF specification, version 2.2,” says Ed Burns, consulting member of the Technical Staff at Oracle and the specification lead for JSF. Just last week, he said, Oracle "released a milestone 1 snapshot implementation of that specification, which is still very much in active development.”

 “It's in a healthy state,” says Ray Ploski, director of Developer Programs and Strategy at Red Hat. Two implementations of JSF exist, Mojarra and MyFaces, and there is “a very competitive and rapidly moving component ecosystem surrounding it. The spec is under active development, bringing in the changes recommended by this large ecosystem it supports,” Ploski said.

Companies that are using Java Enterprise Edition often adopt JSF, says Kito Mann, principal consultant at Virtua, Inc. “It’s more popular for applications that have complex user interfaces,” he says, noting that JSF increasingly is used in insurance, government and financial applications.

“A lot of large corporations and government organizations are adopting JSF as a standard throughout the organization,” said Ted Goddard, chief software architect at ICEsoft Technologies, Inc. “That fits in with the sweet spot of what JSF is intended for – highly interactive enterprise applications,” he added.

JSF not a JavaScript replacement

Just don’t expect JSF to ever supersede JavaScript. “It's… not an either-or proposition,” says Mann. JSF “has component libraries, which are widgets like tables, trees, buttons and spinners. Almost all of those now use JavaScript. The benefit, though, is that [JSF] works really well for developers who are more familiar with Java than JavaScript. You can get by with writing a lot less JavaScript.” But in most complicated applications, developers will still have to write some JavaScript. JSF will do the heavy lifting, he says, so the developer doesn’t have to write as much by hand.

“Ideally, [JSF] will target HTML, because it’s built using tags,” says Goddard. In that way, JSF resembles HTML. JavaScript is used as a “glue language,” but in terms of building a complete, JavaScript-heavy application, Goddard recommends against using JSF. Instead, developers should use Java Web Toolkit (JWT), where the JavaScript code is produced as an executable, or they should instead work directly with JavaScript using jQuery.

Best practices are important when using JSF, according to experts. Ploski advises developers to keep the component tree size in check, try not to be too aggressive with Asynchronous JavaScript and XML (Ajax) updates, and be aware of the typical DRY and code-reuse issues. “Also, I’d say leveraging CDI with JFS is an emerging best practice,” says Ploski.

Meanwhile, Goddard advises choosing a component library and using it throughout the application being developed. “Avoid the use of component bindings in [JSF], because that drags the model into the view and makes it more difficult to maintain the code. [Developers] need a more declarative approach when building [JSF] pages,” he says.

Another useful best practice, according to Burns, is to not “blindly buy into the hype that Data Transfer Objects (DTOs) are an anti-pattern. When used correctly, and especially with JSF, DTOs can provide just the right abstraction that enables loose coupling and minimizes application maintenance headaches,” he says.

Developers also need to work with the framework instead of against it, says Mann. “Sometimes people add functionality and features to their application and build a framework on [JSF] without understanding the way that it works,” he says.

A pet peeve of Mann’s is letting exceptions “bubble up” to the JSF exception handle. “Don’t eat exceptions,” he cautions. “It screws up the user experience because something is out of sync in the application.”

If developers follow best practices, JSF is an excellent complement to HTML5 for building front-end applications, particularly as mobile browsers continue to gain steam. All mobile browsers are HTML5 browsers, according to Goddard.

“HTML5 lets you put most of the UI processing on the client, but you must very carefully consider the consequences of that choice in terms of security, and cross-browser portability,” Burns says.

JSF can target different markup types, says Mann. “You could have different pages for HTML5 and an older version of HTML,” he says. “You could have different pages for mobile devices, and they could all use the same back-end code.”

Expect more opportunities for HTML5 with JSF 2.2, Mann says. Better portlet integration and flow management are expected in 2.2. “One of the things we're looking at is … reducing the server side footprint,” he says. Cloud support is coming as part of Java Enterprise Edition 7, and JSF will work well with that, since it already runs in the cloud.

“Because of the way [the] technology is defined, it’s good at adapting to other display models,” Mann says. “The same application can be updated to work with a smartphone or HTML,” and that’s one of the biggest benefits, that JSF can keep supporting new technology as it becomes available.

Christine Parizo is a freelance writer specializing in business and technology.  She's based in West Springfield, MA.  Contact her at [email protected]

Dig Deeper on Topics Archive