JEE and Web 2.0
December 21st, 2006by Jeremy Thomas
It’s difficult not to mention Rich Internet Applications (RIAs) when talking about Web 2.0 or Enterprise 2.0. There’s one particular framework that stands out, and that’s Ruby on Rails. I have a lot of experience building enterprise applications in J2EE (or JEE as it’s called now) and .NET and wanted to understand what Ruby on Rails was all about.
So, I bought Agile Web Development with Rails – Second Edition. I read every page and did every tutorial (building a shopping cart application with a little AJAX magic).
Rails impressed me. Ruby did not. Ruby was invented in Japan in 1992 and was used without Rails until Basecamp came along and built Rails to “webify” Ruby. From what I’ve seen thus far, the Rails (and GEM and Rake) framework could have been created for any language. It seems that Basecamp had a bunch of Ruby programmers who one day decided to make Rails for Ruby because that’s what they knew. If instead Basecamp had a bunch of Java programmers we could be dealing with Java on Rails (although Java requires compilation, Ruby does not, so Rails might have ended up a little different).
What don’t I like about Ruby? For one thing, the method naming convention drives me nuts. In Java the convention is to use camel-casing, i.e. getCustomer(). But in Ruby, the convention is to use an “_”, i.e. get_customer. Furthermore, I can optionally insert the “()” (get_customer()), it doesn’t matter. Unbridled, the free-form and “flexible” nature of Ruby syntax could lead to unwieldy code, where one Ruby programmer finds it difficult to maintain another Ruby programmer’s code due simply to style differences (i.e. optional use of the return statement, optional use of {}). Furthermore, it is always better to detect and debug errors at compiletime rather than runtime, as runtime errors can often go unnoticed or be the result of something that happened 3 method calls ago (Ruby is a scripting language and is thus not compiled).
Ok, perhaps I’m just stuck in my ways. But, after reading my book I wanted to see if I could implement some of the cool AJAX and Scriptaculous features in a JEE application.
The first MVC (model view controller) I learned was ASP.NET. After 2 years of that I switched the JEE world and found a roughly comparable framework in Java Server Faces (JSF), and specifically Apache’s MyFaces implementation. JSF has a lot of support from the heavyweights in the software engineering industry including Sun, Oracle and IBM.
As of version 1.1.4 of MyFaces, AJAX does not come with it out of the box. So I found a great opensource project called Ajax4Jsf which essentially AJAXifies JSF applications. After resolving some version conflicts I was away, AJAX and all. Last I added visual effects with Scriptaculous and I was away.
The moral of the story is it is certainly possible to build Web 2.0-style interfaces using JEE, so there’s no need to abandon your Java programming skills just because people say “AJAX”, “visual effects” and “Ruby on Rails” in the same sentence. And certainly with mainstream adoption of data access frameworks like Hibernate it’s possible to simplify the process of database interaction in Java.
Follow Me on Twitter
Co-Author
Leave a Reply