Ajax Toolkits, Widgets and Rails

Originally I planned for this post to be a sort of how to for creating floating content panes in a Rails application. If you’re unsure what I’m talking about have a look at protopage or Winlike for decent examples. I didn’t want to write everything from scratch so I began a search for reusable code in the form of a widget that I could use that would make sense for the example. What I found was that there’s a lot out there and there are different approaches to web based widgets. What follows are a few of the things I found and an open question on what the best approach may be.

One of the first toolkits I looked at was qooxdoo (pronounced cooks-do). qooxdoo is open source and is an entirely javascript based widget system. This means that you’re writing scripts to create and place all of the widgets. The demos are impressive, but the documentation is pretty sparse. I was able to get a few things running by looking through the demo code but I didn’t bother to attempt to wire up anything to a Rails backend. After a few hours of playing around I came to the realization that pure javascript widgets don’t seem to make much sense for a Rails application. Since the widgets are created through script calls on the page, ERB won’t be able to populate the content they hold. Are pure javascript widgets useless for Rails developers?

After mostly discarding the idea of pure javascript widgets, I moved on to have a look at the dojo toolkit. I was very impressed with the Rich text widget and have high hopes for future developments. Since dojo lets you declare widgets using HTML attributes it seems like a better approach for Rails applications. This way you could use ERB to populate any content that the widgets hold. I was able to find a demo of a floating window with Dojo, but it doesn’t seem to be in the currently distributed build. I grabbed the nightly build (which had the code for a floating pane), but still had problems getting some code of my own using it. The documentation for Dojo is extremely sparse so I didn’t find it helpful for this endeavor. The rich text widget is by far the best documented control in the toolkit. Dojo looks promising but seems like it has a bit of work yet to be done.

Next I was hoping to get a look at the Zimbra AJAX Toolkit, but ran into number of problems. First off is that the toolkit isn’t downloadable. To get access to it you’ll have to download the entire Zimbra source (around 150MB) and dig into it from there. The documentation is also nonexistent beyond the whitepaper I just linked above. The torrent finally completed while writing this. An initial look through the source shows that they’ve implemented an MVC architecture in javascript for most of the widgets. The backend code is java so it would probably be painful to adapt this toolkit for Rails use. It also looks like it has the same problem of qooxdoo in regards to bringing in data using ERB.

There are certainly plenty more AJAX toolkits out there but I’m looking specifically for ones that have prebuilt widgets to make my job of creating a web application easier. Are there other toolkits I should be looking into? Are there capabilities within Rails that I’m overlooking? One of the thoughts I had while doing all this was that Rails could easily have a widget system of its own through partials and components. Is there a project already in place to do this? In any case this is something I’ll need to figure out. It’s best not to reinvent the wheel but I may end up having to write something of my own to handle this problem.