Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/suresk/jsf-resources.com/wp-includes/functions-formatting.php on line 76

I’ve spent a lot of time developing web applications in JavaServer Faces (JSF). Based on interactions with other Java developers (both in person and via the internet), I’ve come to realize there are a lot of misconceptions regarding JSF, and have attempted to address a few of them here.

1. You need to create a ton of custom components

This is perhaps the biggest misconception among people with a little exposure to, but little or no experience with, JSF. Teams can (and indeed have) spent tons of time creating custom components for a project. This is not necessary or wise.

There are very few instances where a custom component is actually required - in several years of JSF development, I can think of fewer than 5 times I felt like the only way to accomplish something was to create a custom component. In many cases, you can gain a lot of efficiency and reuse from a component and it is advantageous to create one, but this doesn’t mean you have to spend the first 3 months of a project creating them.

In a lot of cases, we’ve found that implementing functionality you are looking for without making a component first, then refactoring it into one later creates the best results. In fact, in cases where components have been built up-front, they often go unused or require heavy refactoring once someone actually uses them anyway.

2. JSF is a Web 2.0 framework

I’ve seen a few people try to compare JSF with Web 2.0 frameworks, or even characterize it as such. It isn’t. You can plug Web 2.0 functionality into it quite easily (ie, using Rich Faces, ICEfaces, or Ajax4jsf), but it isn’t specifically a Web 2.0 framework.

3. JSF is JSP 3.0

Given that JSP is used as the default templating language for JSF, I guess a few people are bound to call JSF “JSP 3.0″, but they are wrong. Granted, projects that have used JSPs in the past may replace straight JSP usage with JSF (although they may still use JSPs as the templating language), but that doesn’t mean JSF is really a successor to JSP.

JSPs are simply containers of logic, Java code (ugly!), and some tags to encapsulate other logic and presentation. JSF is a component-based, event-driven web application framework that also handles the full request/response lifecycle, validation, conversion and more.

4. You need a visual editor (or other tool support) to use JSF

I heard this one a lot, especially when JSF first came out. Yes, JSF does give greater potential for visual editors (ie, like Visual Studio), but you aren’t really required to use one. I’ve only dabbled with a few visual editors for JSF, and have not been impressed with any yet - and the design/development cycle I’ve encountered on most projects would not lend itself particularly well to this either.

There is a need for better tool support for things like code assist and refactoring, but companies like JBoss are working on this.

5. JSF constrains layout and design choices

There certainly are some design approaches that lend themselves better than others to JSF development. That said, in most cases, JSF makes it far easier to implement designs from designers and even allow them to modify JSF pages once you’ve created them - especially if you are using Facelets. In most cases, components are fully stylable and don’t add any extra HTML that would foul up a design - the radio button component being a notable exception and one case where I found it necessary to create a custom component.

This is the process I have found best for developing JSF pages efficiently and allowing the designer to contribute the most:

1. Designer creates page in proper XHTML and passes it off to a developer.

2. Developer replaces pieces of the html that need to interact with the code (ie, input boxes and data tables).

3. Designer is free to modify the layout of the page via the HTML or using CSS.

In short - there may be better choices than JSF for a particular project out there, but I feel JSF provides a lot in terms of development speed, readability and refactoring, and reuse. It is unfortunate how so many developers seem to have some weird misconceptions of it - my experience has been that once people start using it, they really like it and the misconceptions go away.