Professional Scrum Master, Project Manager, IT Business Architect (JEE, Spring, ICEfaces/JSF) Author of the book "ICEfaces 1.8: Next Generation Enterprise Web Development" Rainer has posted 13 posts at DZone. You can read more from them at their website. View Full User Profile

How to Start the JSF Dance

03.09.2008
| 11902 views |
  • submit to reddit

Last week our project structure changed a bit and I had to think about training new members in the JSF field. I remembered that there's still a draft article, I started in 2006, in my blog management. Rick from DZone told me that there's still a need for giving some tips in JSF programming. So, I polished my article ;-).

Hint: If you still think about changing from your current Web presentation framework to something new, keep in mind that Flex/AIR are on the horizon. If it is possible to break with the markup presentation tradition in your project I suggest to have a look at Flex, first.

Background

I'm doing JSF for about 20 month now. I had a look at Apache MyFaces, Trinidad, Tomahawk, Facelets, Woodstock, JSFTemplating and ICEfaces. Short after ICEfaces became Open Source I implement with it.

ICEfaces eliminated the integration nightmare with Facelets, a templating framework that is a must have for our project. ICEfaces delivers its own Facelets jar. We use this framework for some month now in a productive implementation. It has it's tweaks, but the presentation is convincing. And we have a bit of AJAX without JavaScript coding.

I've no problem with JavaScript. I implement with JavaScript since 1997. I did my own client-side search engine and portal framework with it. For me it was even in 1997 a full-blown development environment when we got JavaScript1.1, and nobody talked about AJAX ;-). But, in context to JSF it becomes a maintenance hell pretty soon. You may have a look at the Woodstock table when you try to implement something reusable.

JSF Introduction

JSF may be a pretty cool standard in comparison to existing Web technologies, like Struts, JSP, Servlets or native CGI. I don't think it is pretty cool from a classic GUI developers point of view, but it's a first step in the right direction. But, there's still a problem: besides mature implementations we still need better documentation, sample code and tutorials for the implementation process and the use of JSF components.

I think we still miss smart components and tools that allow to "point-and-click" data into the presentation layer. Imagine you could select a non-visual database table component, a JSF table component, set some attributes to inject the data and deploy this to your application server. Not noteworthy to a VB or Delphi developer even 10 years ago. For Java developers still a challenge.

But, for now lets have a look at what can help to get working code in an acceptable time frame. We have to have a look at general aspects of JSF and the implementation-specific aspects. This is especially important for all the components that are not part of the JSF standard specification.

Although, you may find common aspects you can't expect that you can create a backing bean of a non-standardized component the same way in different frameworks. Trinidad, e.g., needs another data structure to fill a tree than Tomahawk does. Although, it is possible to use the same backing bean if you add a method that converts the structure for Tomahawk to Trinidad then.

JSF in General

I don't know if it is really necessary to study the JSF specs. Most of the spec documents are written in a boring style and are not easy to understand. So, you may have a look at a pretty good presentation from Sun for a first overview.

JSF Tutorials is a comprehensive collection of links that covers introduction up to writing your own components. A similar collection of links is Java Server Faces Resources. Rick Hightower wrote a JSF 1.2 based tutorial (part 2; needs a DeveloperWorks account).

JSF Implementations

Although, the title is a bit misleading Lean JSF delivers a quick reference for important JSF implementations. The presentation of Marty Hall gives an overview and some experiences with the different Apache Frameworks (MyFaces, Tomahawk, Tobago, Trinidad is main focus).

Here's another one in German: Vergleich von JSF-Frameworks mit AJAX-Integration (PDF link).

Here's a tutorial that shows some details of Tomahawk: Build Apache Geronimo applications with Java Server Faces (Needs a DeveloperWorks account)

JSF Tools and Environments

Although, JSF is like working with extended Struts plus Java hacking, it's a good idea to use an IDE and not only a text editor. You may miss really cool GUI designers at the moment, but all IDEs help to get the XML files under control. For a better overview of environments, frameworks and IDE support InfoQ has different articles. The JSF Central Community can help here, too.

Rick Hightower is doing a lot of stuff in the JSF, Spring, Hibernate, JSF, Facelets and Eclipse domain. He's started the SHJFT tutorial that can give you extra information to stuff you may read about in my blog.

Open IDEs to have a deeper look at:

  • Eclipse JSF Tools Project (The PDF shows how far this is gone. Pretty nice ;-).)
  • JBoss Developer Studio (based on Exadel's Eclipse work and was free for some time; but pretty good for Facelets and RichFaces; you can add other Taglibs for tag support, works e.g. with ICEfaces)
  • Netbeans (extension based on the Java Studio Creator work and pretty good for Woodstock, but you may be dependent from Sun's DataProviders)
  • JDeveloper (For ADF Faces and Trinidad, even Visual Designing)

ICEfaces delivers plugins for Eclipse, Netbeans, JDeveloper, etc. Maybe still interesting to some projects is the Faces Console.

JSF Code to Start

Although, the usefulness of code-starters depends on the frameworks you will use in your projects they may help to get a better understanding of the glue you need.

The all-in-one device suitable for every purpose is Matt Raible's AppFuse. It started as a helper to learn Java. But, it is already a showcase for the most important Java frameworks and the glue between them. For our Trinidad friends Faces Goodies maybe helps for better understanding.

Books

The list is not complete, have a look at Amazon comments in any case, but here are some that got my attention:

Blogs

Blogs become more and more important. Especially, if documentation is missing and you search for experiences. A lot of developers share their experiences this way. And you can also use the blogs for bi-directional communication, instead to wait for an answer in a forum. Here's a list of guys, writing about JSF in general and also about specific frameworks, you should have a look at:

Critics

Although, JSF becomes the de-facto-standard for markup-based client presentation, don't think that you get a better approach than you have today with Struts plus AJAX extensions. The better strategy may be to wait until Flex is mainstream in development and than thinking about porting to a real GUI presentation. Some thoughts and experiences from the community:

Architecture and Framework Stacks

There are architecture stack changes today that are also influenced by the client presentation (e.g. if you change from JSF-based backing beans to Spring-based ones). Some weeks ago I found a presentation that describes a similar architecture we use successfully today in our project:

Advanced JavaServer Faces

We've also Crank in our architecture. Meanwhile Rick Hightower has a presentation about Crank. Although, Architecture details is a bit small in the presentation (have a look at slide 11).

The missing ICEfaces support, resp. porting costs, let us skip the JSF support, because Crank uses another AJAX framework. But, we like the generic DAO/JPA stuff. It let us design a pretty clean layer. And ICEfaces support will come, so that we get a more scalable table presentation then ;-).

References
Published at DZone with permission of its author, Rainer Eschen. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

John Denver replied on Sun, 2008/03/09 - 10:06pm

Instead of Flex learning new framework, another platform and how to integrate with Java it takes time, better wait for JSF 2.0 or if you want results now Tapestry 5 deliver all the goodies, very easy to create ajax based components and you don't need to write a single line of xml or you don't need a GUI designer, It is a very simple, clean framework, JSF 1.2 it is crap compared to Tapestry 5, T5 rocks.

Rainer Eschen replied on Mon, 2008/03/10 - 2:19am

Thanks for your hint. I didn't have a look at Tapestry, but I assume it's part of the markup-based presentation world. I prefer Flex, because of its presentation mimic. It delivers desktop-like presentation. In future we will need this, because the users demand for a desktop-like mimic will increase. Even the necessary extra training and some integration aspects, like using Spring with it in the backend, that may be in development at the moment, are worth to invest. For all who still use Struts, I think the change to JSF is an unnecessary intermediate step towards real desktop-like presentation, that does Flex best (of all offers we're talking about at the moment).

And it seems to me that we will get an even more intuitive development with Flex. Adobe does a good job in supporting their "Flash designer customers" in software development aspects. For us, this idea can ease the client development in any case.  

Richard Bremner replied on Mon, 2008/03/10 - 3:41am

I think you are obsessed with Flex. "Not the 6 minute workout! 7 Minutes!".... "Not JSF, Flex!" 

Mark Haniford replied on Mon, 2008/03/10 - 8:40am in response to: Richard Bremner

He probably just understands the limitations of HTML, CSS, and Javascript, and that you'll never get the desktop technology with those technologies.

Rainer Eschen replied on Mon, 2008/03/10 - 3:24pm

Thanks Mark, you're right! It feels like being in the stone ages for years.

Pretty interesting that I have "to fight for better user experience" in the Web arena when my experience tells me that a decade ago I had better tools and was able to produce better user interfaces.

Even if I consider the shift in programming, the network in the center architecture, etc. I can't accept that I have to wait more than 10 years to get something similar for the Web. But, even AJAX doesn't deliver it yet.

John Denver replied on Mon, 2008/03/10 - 10:20pm

I'm sorry but the Web never meant to replace the desktop, The architecture of the web will never be as the desktop. If you want distributed system's with a thin client that behave as a desktop app so yes flex with adobe air is a good choice or you can even try JavaFX will integrate better with Java technology than Adobe one. And if you really are obsessed  that the future will be desktop like apps why not we resurrect Java Swing, Delphi or Visual Basic  to develop real desktop applications.

I don't understand why people wants to continue to create desktop like apps over the web is a stupid idea, we have to adapt to how is the web and try to develop applications that adapt to the new architecture and try to simplify the UI so the user get comfortable using the apps across the globe but it doesn't have to behave as a desktop app, everything is changing the operating system's are not relevant at this times, the network and the web are the new operating systems. 

Mark Haniford replied on Mon, 2008/03/10 - 10:37pm in response to: John Denver

There's no reason you can't have the desktop UI experience on the web. Flash, silverlight, and even applets have problen that. He's not talking about desktop apps, but apps in the browser that have the UI like the desktop

I don't understand why people wants to continue to create desktop like apps over the web is a stupid idea,

Because they don't want their apps to look and feel like crap.

we have to adapt to how is the web and try to develop applications that adapt to the new architecture

How about the web adapts to how "we" want applications to look and feel.

try to simplify the UI so the user get comfortable using the apps across the globe but it doesn't have to behave as a desktop app,

Web apps (even all ajaxified up) are still clunky to me.

everything is changing the operating system's are not relevant at this times, the network and the web are the new operating systems.

Larry Ellison and Schwartz said this a decade ago and it never came true.

 

 

 

Peter Thomas replied on Wed, 2008/03/12 - 6:02am

Nice article but I get the feeling that you are a reluctant JSF evangelist and your heart lies with Flex. "How to start the JSF dance" sounds suspiciously like a subliminal reference to all that dancing around the different JSF implementations and Ajax and all you have done : )

Anyone using JSF + Portlet (JSR-168) + Ajax and would you recommend this combination? Someone is demanding this for an upcoming project but I'm not sure. Its confusing because people are now talking about JSF2 and JSR-286 is close to approval.

You have a typo in the link "Lean JSF" it should be "Learn JSF"

Richard Bremner replied on Wed, 2008/03/12 - 6:23am

I think Mark hit the nail on the head. The real problem is that all these frameworks we scuttle around to learn are trying to make the web "work". It's not really the frameworks that are crap, it's the web. Maybe we should start from scratch, forget http, create a whole new protocol that truly suits our requirements and create one easy to use (because it's doing what the protocol was designed for) framework.

 The other problem is that say we have invested 2 years learning JSF, so now we should drop JSF and learn Flex because thats the future... no wait this other guy says JavaFX is the future maybe I should learn that too just in case. What's that? Silverlight is the future? Ok, I will quickly learn .NET and Silverlight. I don't know about you but some of us have a job to do and cant spend all day every day learning bloody web frameworks.

 

...Spring, Struts, Facelets, Tapestry, Wicket, blah blah blah, how I wish they would all go away :-) 

 

John Denver replied on Wed, 2008/03/12 - 9:16am

- Mark I respect your point and the author but I think this article is very biased to Flex. 

- Richard thats competition, it have to be competition so it comes innovation.

I dont have a problem to learn new technology, if you know one framework is easy to jump to another and now more with the help of IDE's and code generations tools and many more.

So I like there is JSF, Tapestry, JavaFX, Wicket, Spring, so on.That keep the Java platform live and well. 

 

Richard Bremner replied on Wed, 2008/03/12 - 9:38am

Absolutely I agree, competition is a good thing. Imagine all the cars on the road had square wheels, great there is loads of competition, but yet none of the cars are particularly suitable for the road... this is IMHO the current status of web frameworks - they are trying to patch something together to make the square wheels rounder.

 Maybe I'm being too abstract, oh the irony  :-)

Rainer Eschen replied on Fri, 2009/02/13 - 7:40pm

I started a new project for AppFuse and ICEfaces integration:

http://icefusion.googlecode.com/

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.