Rails, Ajax, RJS, and Testing

As promised, today’s entry is Agile and Ajax. Also, it’s a dessert topping.

Ajax in Rails

The initial support for Ajax calls in Rails was centered on two framework methods called link_to_remote and remote_form_tag. The basic functionality of these methods is to allow a remote call to be triggered by a link or form submit and have the result of that call be used to update a DOM element somewhere on the page.

Moving outside that simple behavior, however, quickly got messy. Both methods specify a series of callbacks where arbitrary JavaScript can get implemented at various points in the call life-cycle. However, writing dynamic JavaScript in an ERB template is awkward, and the resulting method calls could get ugly.

Enter Ruby JavaScript (RJS), sometimes described as “training wheels for JavaScript”. RJS allows a very simple subset of JavaScript to be written in Ruby and translated to JavaScript as the result of a Rails Ajax Request.

Here’s what a sample RJS template looks like:

page.visual_effect(:fade, 'recipes_to_show',  :duration => 0.5)
page.visual_effect(:fade, 'category_being_shown', :duration => 0.5)
page.delay 0.5 do
  page.replace_html("category_being_shown", 
    "Recipies For: #{@category.capitalize}")
  page.replace_html("recipes_to_show", :partial => "recipes")
  page.visual_effect(:appear, 'recipes_to_show', :duration => 0.5)
  page.visual_effect(:appear, 'category_being_shown', :duration => 0.5)
end

The page variable is automatically provided by Rails and represents the page that is going to receive the JavaScript. There are about a dozen or so instance methods that page can receive, mostly having to do with the basic Ajax-y features of replacing HTML in a DOM element and calling Scriptaculous visual effects. This particular snippet fades out two elements, changes their text, and fades them back in for a crossfade effect.

(There’s a certain similarity of concept with Google Web Toolkit, but RJS is going after a much smaller and more focused piece of functionality, optimized towards what you would do in a single Ajax call in an otherwise standard interface. GWT, on the other hand, is trying to be the entire application on both the client and server side.)

How useful this is depends on your relative level of comfort with Ruby and JavaScript. I’m personally much more comfortable in Ruby, so I think this is just great. It’s especially nice since I can use Ruby blocks to abstract this crossfade function into something I can use generically.

def crossfade(page, *dom_ids)
  dom_ids.each do |dom_id|
    page.visual_effect(:fade, dom_id, :duration => 0.5)
  end
  page.delay 0.5 do
    yield
    dom_ids.each do |dom_id|
      page.visual_effect(:appear, dom_id, :duration => 0.5)
    end
  end
end

The generic function takes a list of DOM ids and a block — the assumption is that all the content changing will be managed in the block. So the original snippet would now be changed to:

crossfade(page, 'recipes_to_show', 'category_being_shown') do
  page.replace_html("category_being_shown", 
      "Recipies For: #{@category.capitalize}")
  page.replace_html("recipes_to_show", :partial => "recipes")
end

If you’re feeling more adventurous, you can patch the crossfade method directly into the JavaScriptHelper class and change the call to page.crossfade, making it more consistent with the other calls performed in an RJS template.

Testing RJS

Now for the Agile portion — how do you test this thing? RJS templates can be tested pretty thoroughly based on the content of the JavaScript code being generated. It’s much harder at the moment to test based on the actual results of the JavaScript — for example, it’s hard to test that the DOM elements being referenced actually exist in the client page.

There are two mechanisms for testing RJS that I’ve found useful. The first is mock object testing. Using the flexmock package to set up the page as a mock object, a sample test for the crossfade method looks like this:

def test_crossfade
  page = flexmock("page")
  page.should_receive(:visual_effect).with(:fade, "dom_1", :duration => 0.5).once.ordered(:first)
  page.should_receive(:visual_effect).with(:fade, "dom_2", :duration => 0.5).once.ordered(:first)
  page.should_receive(:delay).and_yield.once.ordered
  page.should_receive(:replace_html).once.ordered
  page.should_receive(:visual_effect).with(:appear, "dom_1", :duration => 0.5).once.ordered(:last)
  page.should_receive(:visual_effect).with(:appear, "dom_2", :duration => 0.5).once.ordered(:last)
  crossfade(page, "dom_1", "dom_2") do
    page.replace_html()
  end
end

Without going into the details of flexmock because, hey, future blog post, the idea is that the mocked page object keeps track of the method calls it receives and checks them against an expected set of method calls. In this case, I’m telling the mock object that it should get two calls to the visual_effect method with various arguments, and that those calls should come before the other calls.

The interesting thing about this method is that on the face of it, it contains no assertions. Implicitly, though, each should_receive call sets up an assertion about the messages coming to the object that is validated at the end of the test.

The other mechanism uses a plugin called ARTS (Another RJS Testing System), which defines a method called assert_rjs, which checks the outgoing JavaScript for a method call matching a set of parameters.

Using ARTS, the following method tests whether an individual DOM element is in the crossfade:

def assert_crossfade(dom_id, replacement)
  assert_rjs :visual_effect, :fade, dom_id, :duration => 0.5
  assert_rjs :visual_effect, :appear, dom_id, :duration => 0.5
  assert_rjs :replace_html, dom_id, replacement
end

And a full test of the example would look like this:

def test_one_crossfade
   assert_crossfade 'recipes_to_show', /Recipe/
   assert_crossfade 'category_being_shown', /Category/
end

The replacement argument can be either a string, in which case the output needs to match exactly, or a regular expression, in which case a Regex match is performed. In general, assert_rjs works by recreating what the JavaScript looks like from the assert call, and checking the actual output for the existence of that call. Again, this is most helpful when you can bundle calls together in a single assertion.

ARTS is a nice little plugin, and it does let you do some syntactic testing of your RJS templates, but semantic testing along the lines of, is the recipes_to_show element visible at the end of the RJS and what text is actually in the element is still elusive. I think that’s doable, but it would require a much more complex mock object representing the page, one that keeps track of a pseduo-DOM tree and can manage at least some of the effects of RJS calls. Another project for another day…

Cognitive Load, Portability and the Superiority of Client-Side Frameworks

The recent introduction of TrimPath Junction got me to thinking about Dietrich's widely read post on Cognitive Load and the Superiority of Server-Side Ajax GUI Frameworks. GWT's big advantage is that it mobilizes armies of Java programmers to write browser-based applications without having to learn JavaScript. This is clearly of enormous benefit to organizations with lots of Java programmers, few client-side resources, and a burning desire to build powerful webapps. Yet for the similarly huge army of client-side programmers out there, GWT is pretty useless. Why learn a foreign language just to have it translated back into your native tongue?

I haven't yet had a chance to play with TrimPath Junction, but it sounds pretty cool. Using the open-source Helma framework, it offers Rails-style MVC scaffolding in a JavaScript syntax that executes the same code on the client and server. Basically, it's RoR meets Adobe AIR for JavaScript programmers. I hope to give it a test drive soon.

Server-side JavaScript has been around for ages, but it's never really become a common development model. I remember writing ASP Classic apps in server-side JScript back at the turn of the millennium and having people wig out on me. "Why not write in VBScript like everyone else," they'd ask. My answer: "Because I can save time by running the same validation libraries on the client and the server ... and because I can write the entire app in one language." I obviously have no argument with Dietrich's thesis on cognitive load. It's just that my brain features a JavaScript compiler, not a Java one.

GWT is a great piece of engineering that keeps getting better; just check out the new non-beta 1.4 release. But I think there are a lot of advantages to frameworks that mobilize the JavaScript masses to write front-to-back webapps. The same cognitive efficiencies can be achieved, plus client-side programmers already know all the pieces of the UI puzzle. Ask a room of Java developers how to build accessibility and usability into standards-compliant XHTML and CSS. Nine out of 10 wouldn't have a clue.

The other big advantage to developing UI code in its native language is that you can port it to any server platform. With GWT and similar frameworks, you've got to rebuild much of your UI from scratch if you want to change course in mid-stream. With purely client-side frameworks such as Prototype, jQuery, YUI or MooTools, switching libraries may entail rewiring some of your code to a new API. But switching server platforms, from J2EE to .Net to PHP to RoR, can be done without much work at the UI layer. "The right tool for the right job" is a truism for a reason. Pure client-side development of UI code allows for the development of reusable components whose only dependency is on the standards bodies and browser vendors who control JS, CSS and HTML. GWT and its peers are useful for some teams and some projects, but they're not the only answer to webapp development.

jQuery vs. Prototype: OO JavaScript with or without training wheels

After brushing up on jQuery via a little light reading, I've started to play with the framework in code. I'm demoing a scrolling news ticker and decided to write it using jQuery and its Interface plug-in. Future iterations will probably include the history and easing plug-ins, too. In the meantime, though, it's been two steps forward, one step back. I really dig the elegance of the jQuery API and its concise method-chaining. But there's one integral element of the Prototype/Script.aculo.us framework that I miss: The Class object and the OOP training wheels it provides.

For developers like myself - long-time UI folks who have used JavaScript's Object datatype for years but lack significant experience writing in a strongly typed, truly object-oriented language like Java - Prototype has been a revelation. It doesn't enforce OOP principles, but it encourages them. And its source code is like a Rosetta Stone for how to implement them in the dynamically typed, prototype-based world of JavaScript.

There's been lots of discussion over the past year about the deficiencies of Prototype's inheritance scheme. A lot of the syntax is ugly, and Object.extend is easy to overuse or misuse. The new 1.6.0 release candidate appears to address some of those weaknesses by augmenting the Class object's API. Regardless of your position on this debate, though, it's hard to ignore the fact that Prototype has helped a lot of front-end folks improve their half-assed understanding of OOP. Personally, I wouldn't even be in a position to follow the discussion if I hadn't spent the last 18 months or so writing Prototype-backed JS classes. Thanks to the patterns to which this library has exposed me, my grasp of JavaScript - and of software engineering in general - has grown by leaps and bounds.

Once I started using a different library, though, Class.create was suddenly useless. I had to figure out different inheritance and encapsulation strategies. The training wheels were off, and I had to find my own of balance. My first hurdle was figuring out how to organize my jQuery procedures into reusable methods. I felt totally adrift without the built-in ability to bind functions to their execution environment; the this keyword was always assigned to a DOM node. I thought about simply porting Prototype's Function.bind and Function.bindAsEventListener methods, but that seemed at odds with the design of jQuery's own API. Finally, I turned to Douglas Crockford's module pattern for JavaScript. Now I had a new way to organize my objects and methods in a reusable way that worked well with jQuery. By defining private methods inside of a closure, I could access those methods with simple function calls, no binding necessary. As with Prototype, a whole new world opened up.    

A lot of developers worry that Ajax frameworks make for lazy programmers, but in my experience the opposite is true. Each new design pattern or framework that I play with teaches me new approaches to JavaScript and OOP in general. Folks coming at UI development from, say, a C++ background may want a framework that enables a well-defined inheritance model. But OOP scaffolding is a separate concern from Ajax and DOM tools. Prototype provides both, while the base jQuery library provides only the latter. Still, somebody could easily write an OO plugin for jQuery - or several of them, each implementing a different inheritance model.

Simon Williamson's recent post on jQuery for JavaScript programmers does a good job of explaining how jQuery encourages good OOP techniques. The walled-off namespacing represents a different conceptual model from Prototype's. Until you understand both, it's difficult to see all the strenghts and weaknesses of either. As with other tool, the key to these frameworks is learning what tricks and tradeoffs each one supplies, and why. Up next: YUI and Ext.

The awesome state of JavaScript development tools

Dietrich's post on the depressing state of IE develpment tools got me to thinking about the generally wonderful state of JavaScript tooling. Compared to just a few short years ago, we've got a wealth of productivity-enhancing browser add-ons, TDD frameworks and static-analysis tools at our disposal - most of them open-source. For those who want to get their hands dirty writing POJ, this is a golden era.

Like most developers, my code circa 1998 was filled with commented-out alert() statements. I spent way too many hours cursing IE4's inability to report accurate line numbers in its error dialogs. I relied heavily on Netscape's built-in debugger. Within a couple of years I had graduated to a primitive logging utility that spawned a separate browser window and output messages into it using simple DHTML. At the time, it seemed like a huge advance.

Then came the Firefox era, with its host of disparate add-ons. You could edit your CSS in the sidebar, selectively disable JavaScript and CSS, inspect the DOM .... Once again, the possibilities seemed endless. Now, thanks to Firebug, most of my grab-bag of browser add-ons are gone. Firebug is so powerful and wide-ranging that the only other add-on I use regularly is the venerable Web Developer Toolbar. Yahoo's new Firebug extension YSlow adds some really useful optimization benchmarks to the suite. When a plug-in begins to spawn its own plug-ins, you know you've got a winner.

I'd be interested to know, though, what kind of process UI developers use to debug their JavaScript. Most of us are using similar tools, but how are we using them? (That's an invitation to jump in on the comments, folks.) Every UI person I know develops prototypes in Firefox and Firebug, crossing his or her fingers that there won't be too many implementation-specific issues to tackle in the other browsers. Many rely on a logging utility - heir to that long-ago popup window - to grind away at any such browser bugs.

But beyond that kind of hunt-and-peck debugging, have we arrived at an industry-standard practice for client-side code maintenance? Who's doing true TDD with one of the flavors of JsUnit? Who's using Selenium to test their entire webapp in the browser? Who's picking apart the details of their syntax with Douglas Crockford's JsLint? Who's busting out Fangs or another accessibility test tool on a regular basis? The tools are out there. It would be interesting to know who's using them, and how.

When you're banging your head against a wall trying to figure out why a certain DOM element won't return the same node type from one browser to the next, it's easy to see why there are a hundred competing Ajax frameworks promising to solve all your cross-browser issues for you. Let's just remember how far we've come - and how important it is for real-deal UI developers to maintain the skills that they've honed for over a decade. The more trust we put in frameworks, the more helpless we'll feel when our code fails and we've lost the ability to figure out why.

The Depressing State of IE Development Tools

A while back I contributed a chapter on Ajax optimization to Real-World AJAX, and as a part of that effort I did quite a bit of digging around for tools to do profiling in IE. The pickings were slim. Now whenever a new book on Ajax comes along, I take it as a point of professional interest to check out its section on profiling and optimization, and so far the lack of progress in tools for IE is depressing. What a contrast, though, between Firefox and IE: while Firefox now has a souped up FireBug and the venerable Venkman, IE's got the same old developer tool-bar, the script debugger and various HTTP proxies to debug XHR and other requests. Of course there's always Visual Studio. Blech. How many virtual machines can you run with IE6 + VS, IE7 + VS? I need a 6GB laptop to get reasonable performance, and even then I don't get profiling.

So, what are the options for profiling code in IE?

  • Tito Web Studio - the old commercial standby. Gets the job done, but be prepared to fork out ~$200 per developer.
  • IEWatch - new commercial kid on the block. I haven't used it yet, but it provides debugging and profiling.
  • You can hand code timing functions using a simple AOP framework like Ajaxpect. That's sort of the approach taken by qooxdoo, i.e. you can instrument the entire app in this way.
  • JsLex - very sweet cross-browser profiler. You deploy it as a war in an appserver and expose it through the same url as your app. On the client side it works by parsing and instrumenting your Javascript code. You can do that either through the webapp's interface or through an ant task. Not quite as simple as Firebug, but still pretty sweet. See this Ajaxian story for some screenshots.

There are a few other things on the horizon, such as AjaxView, a server-side proxy that rewrites and instruments your JavaScript as it is served up. Still experimental. I realize that the above is a potentially bigger concept than a plain old profiler, but how about starting with the simpler ideas and working our way up?


Technorati Tags: , , ,

ZeroKode 0.8 Released

zerokode2.PNG

I've already blogged about ZeroKode, the drag-and-drop visual GUI design tool for ZK. Well, version 0.8 has been released. It's a little slicker, more responsive, but it still has the same issue of requiring a knowledge of the ZK component heirarchy. A lack of popups over the components is also an issue, since the icons are not exactly self explanatory.

This brings up an issue with these new web-based RIA's. I say "new" because they are not new to the desktop, but new to the developers of web applications. These are concept such as the "explorable interface," where the cost in time and effort of trying out things is minimal. ZeroKode fails in this regard in several ways. For one, finding out that a component doesn't belong as a child in the component heirarchy by trying to drag it onto that heirarchy and having to deal with a timeconsuming popup. Further, the properties form for each component is accessed through another popup -- another time waster.

chess.jpg

This is also a reason why an "undo," probably linked up to the back button, is so important in RIA webapps; without an undo, the cost of exploring is high. As anyone who has played chess knows, humans are very good at searching forward, but lousy at backtracking. That's why so few of us are Grandmasters.

Technorati : , , ,

Alert: Security Update for Firebug

Joe Hewitt has released a security update to his excellent FireBug Firefox addon.

About an hour ago I received word of a 0-day security exploit that has been discovered and reported. I have just released a new Firebug (version 1.03) with a fix for this bug, and I recommend that everyone install it as soon as possible.

The update has been published to addons.mozilla.org, so you can get it by updating Firebug from the Firefox Add-ons window. Alternatively, you can install the update using the big orange button on the getfirebug.com home page.


Technorati : , , ,

Javascript, Unit Testing and Code Coverage

Q: Why are there no good Open Source dental practice management software packages? A: Because there are so few dentists who are C++ programmers.

Paul Watson raises the question of why there are no decent code coverage tools available for Javascript:

Am I to think that all those millions of lines of Javascript out there on all those Web 2.0 sites that espouse agile practies with TDD influences don't have code coverage? Sure, some may have unit testing but unit testing without code coverage is a less than ideal situation. You simply don't know if you have tested all functions and all paths in your functions. Unit testing and code coverage go hand in hand, they back each other up.

He has found one commercial tool that is currently in beta, but nothing else. It apparently takes the approach of hooking into the various browser platforms by means of a DLL? I know that there has been some talk about hooking code coverage into Venkman, Rhino and the Komodo IDE. But so far no one is offering a Javascript only, cross-browser solution.

So what are you to do? Venkman at least can give you function level code coverage with profiling, but that's only good for Firefox. Same with the commercial profiler from Tito Software for IE.

Unless the Mozialla and Microsoft guys provide something like this, I don't see it happening in open source. The best open source software is always made by users for users. How many Javascript developers also have the skillset to develop the necessary IE, Firefox, Opera and Safari plugins?


Technorati : , ,

Improving Test Coverage of Ajax Applications

It has been recognized for some time that Ajax applications are a different animal when it comes to testing. In the world of pre-AJAX web applications, the state of the art involved recording HTTP transactions and scraping the resultant HTML pages to check for correct results. That was fine as long as the application was the typical form based, rectangular HTML webapp. With Ajax, all sorts of other considerations come into place, like whether a particular drag and drop action works, not just if the recorded HTTP Request that it's supposed to generate results in the right HTML page or XML message.

The shortcomings of the protocol and screen scraping approach have lead to more sophisticated solutions such as Selenium, a browser based testing solution. With Selenium, all that Javascript can execute and all of those DOM changes can happen and your test scripts can excercise the application through the much more fine grained issuing of interface events. Problem solved, right?

Well, not really. If you're implementing a document based rather than a form based application, getting good test coverage of an Ajax application can be problematic. In the case of a form based application, you have a limited number of paths, so path based, statement based or condition based code coverage measures can all work fine. Now imaging trying to do path based code coverage for Microsoft Word or Excel; the number of interface choices at each point can mushroom like crazy. If the number of UI event choices at each point are no more than 10, then the number of paths after n operations is 10^n.

Fortunatley, this problem of code coverage has been faced once before -- during the move from form-based and command-line based applications to GUI applications. Lots of good research has been done on this topic. Take for instance Coverage criteria for GUI testing by Atif M. Memon, Mary Lou Soffa and Martha E. Pollack (September 2001, ACM SIGSOFT Software Engineering Notes , Proceedings of the 8th European software engineering conference held jointly with 9th ACM SIGSOFT international symposium on Foundations of software engineering ESEC/FSE-9, Volume 26 Issue 5). They propose an approach of dividing up the user interface into a number of components that can be tested independently. They point out that large GUI's are haeirarchicacal, made up of dialogs, panes, etc.

Once an application has been divided into components, all possible events available for a component are identified and an event flow graph is constructed that reflects all possible compositions of events. Then inter-component interactions are identified and an "integration tree" is constructed, i.e. a tree rooted at the main or starting point of the application and connecting to components that are activated via events from another component (restricted-focus, unrestricted-focus and termination events in the parlace of the paper). The paper goes on to describe metrics and testing approaches based on this application decomposition. It also points out how statement-based code coverage can be very misleading.

There are other approaches to testing GUI's, but I hope this one has given you a notion that there is more to testing an Ajax application than turning a Use Case into a test scenario, or that a statement-based code coverage tool will let you sleep well at night over the adequacy of your functional tests.

Technorati : , ,

Built-in Debugging Tool in Echo2

One of the nicer things in the Echo2 framework is something that doesn't get mentioned a lot: a built-in debugging tool. Just add a "?debug" to the end of your application URL, and you get a pop-up like the one below. With it you can inspect the messages passing back and forth between the client and server, inspect the DOM, view platform details and errors, and so on.

echo2debug.jpg

You can always use tools like firebug to supplement what Echo2 offers, but this one you can take what you wherever you go -- IE, Firefox, Opera, Safari, etc.

Technorati : , ,

Three more IDE's I Missed

It seems I missed at least three IDE's in my post from earlier this week.

  • Rialto (Rich Internet Application Toolkit) has released the Rialto Studio, a browser-based visual designer similar to ZK's Zero Kode, though a lot more polished.

rialto.jpg

  • I covered Interakt's Dreamweaver-based IDE, but I missed their JavaScript plug-in for Eclipse. There are plenty of open-source JavaScript editing plug-ins for Eclipse already, so I'm not sure as to the value of a commercial option.
  • JSC is definitely a weird one. It claims to allow you to build Ajax and J2ME applications from C# code. It is supposed to work with any C# capable IDE, including Visual Studio. From their project page:

The compiler extracts CIL from a .net assembly. It filters out the classes which are marked with the ScriptAttribute. It selects the target language and emits the source.

Confused yet? There is a flash movie that demonstrates the workings of their tool, but they are going have to make it a whole lot easier for developers to understand and use their tool if they hope to have anyone adopt it.

  Technorati : ,

IDE's with Ajax Support

Back a few months ago or so, I put together a list of Java IDE's that supported Ajax. Since that time, Ajax support has been added to a few more IDE's, some IDE's on my list have been upgraded, and I've decided to add other languages beyond Java.

Of all the frameworks, GWT has seen quite a bit of growth, with two new eclipse plug-ins entering the list alongside a NetBeans project template. I've also added two Dreamweaver plug-ins, a natural given its long support over the years of rich interaction applications via JavaScript.

Zero Kode, the new visual designer for the ZK framework, joins Tibco GI as a browser-based IDE. Given that it requires a servlet container to run, it may not be suitable for anything beyond prototyping. Still, it shows how easy UI markup languages make the task of writing visual designers.

Before anyone objects, I am aware that there are other frameworks for .NET, Java and other languages. While a particular framework may be in principle supported by an IDE, unless a plug-in or IDE exists specifically for that framework, I have not included it in my matrix.


IDE Type Framework Languages License Comments
EchoStudio 2 Eclipse Plugin Echo2 Java Commercial Framework is open source. Eclipse plugin that allows you to build component trees, preview the UI, debug the application, etc. Not WYSIWYG, i.e. no drag and drop page layout.
Tibco GI Browser Based Tibco GI Javascript Commercial Free for development and publicly available web sites. Eats its own dogfood, i.e the IDE is implemented in itself and runs in IE. Is WYSIWIG and pretty slick.
Google GWT Command Line GWT Java Free Free to use for personal and commercial purposes. As for IDE integration, there's mostly just an Eclipse project generator and a "hosted mode" runtime. Being able to debug Javascript as Java in an IDE has to count for something, though, which is why I've included it.
Morfik WebOS AppsBuilder Custom IDE Morfiks Pascal, Java, C#, VB Commercial Freestanding IDE. Support several source languages including Pascal, Java, C# and VB. Drag-and-drop, WYSIWYG design. The behavior of the GUI designer is a little awkward. For example, right click doesn't give you the ability to cut and paste, etc., necessitating a roundtrip to the window's menu. Doesn't look like they have a whole lot of widgets in the evaluation version. A bunch of ther stuff thrown in, like DB integration, PDF reporting, etc.
JoyiStar Juno Custom IDE JoyiStar Java/JSP Commercial I apologize that I really haven't had a chance to look at is what in any detail. If anyone cares to contribute a review, I'd be happy to post it.
MyEclipse Eclipse Plugin J2EE Commercial With MyEclipse 4.x, the popular eclipse extension added support for JavaScript editing and debugging. With version 5.0, new features are making their way into MyEclipse, such as runtime DOM inspection, HTTP header monitoring, and cache control.
Zero Kode Browser Based ZK zul/Java Open Source IDE written in ZK that allows you to visually design a ZK application.
MX Ajax Toolbox Dreamweaver Plugin PHP Commercial Supports PHP_MySQL and PHP_ADODB on the server side.
Aptana Eclipse Plugin & Custom IDE Multiple Javascript/HTML/CSS Open Source Works with AFLAX, Dojo, MochiKit, Prototype, Rico, sript.aculo.us, Yahoo UI
Yet Another GWT Plugin Eclipse Plugin GWT Java Open Source Forked from Googlipse
Googlipse Eclipse Plugin GWT Java Open Source Wraps the create, run and compile for you.
VistaFei Eclipse Plugin GWT Java Commercial Supports visual design of UI.
GWT Plugin IntelliJ GWT Java Commercial It does all of the messy setup of the GWT Eclipse project and application creation for you. It allows you to create several GWT entities via menus: Module, Entry Point, Remote Service (client and server side classes), and Serializable classes. The automatic creation of a Remote Service with it's three files (shades of EJB) is especially nice.
Backbase Java Eclipse Plugin Backbase Engine/JSF Java/JSP Commercial Plugin based on WTP. Includes new UI component creation wizard.
Backbase .NET Visual Studio Plugin Backbase Engine C#, VB Commercial Under development
Backbase Dreamweaver Dreamweaver Plugin Backbase Engine Commercial
Visual Studio Atlas C#, VB Commercial
NetBeans GWT Project Template GWT Java Open Source
ThinkCap JX Custom IDE ThinkCap JX Framework Java/JSP Commercial A first scan makes me think that this is mostly an afterthought in a J2EE suite. In fact, the documentation states that it is based on struts. The framework is now supposedly open source.
RadRails Eclipse Plugin Ruby on Rails Ruby Open Source Can be combined with Aptana.
Oracle JDeveloper Custom IDE JSF Java Commercial The support here seems somewhat rudimentary.
jMaki Netbeans Plugin JSP/JSF Java/JSP Open Source This NetBeans 5.5 plug-in gives youdrag-and-drop insertion of jMaki components directly into your JSP pages.
Ajax Toolkit Framework Eclipse Plugin Javascript Open Source Open Source Eclipse Plugin. Really more of a toolkit for building other AJAX IDE plugins. Starts by combining Dojo and Zimbra Toolkit. Very early in it's development. From the project docs: ATF enables support of DOM browsing and JavaScript debugging by using Mozilla XULrunner to embed the Mozilla browser component (Gecko) in the Eclipse framework.


If I've left out any IDE's, and I am sure I have, or have made any mistakes or omissions, and I'm sure I've done that too, please don't hesitate to drop me a line at ajax@pathf.com.

Technorati : , , , , , , ,

IDE Watch - Zero Kode, Visual Designer for ZK

The Tibco folks like to point out that their IDE is written in their own framework. I'm not really all that enamored of the self-compiling, eat your own dogfood approach to IDE's when your end product is a webapp. Call me old fashioned, but I like to write my code in a desktop IDE. Maybe that's just a sign that my arteries are hardening and I'll soon be standing on my lawn in my slippers and bathrobe cursing at those webapp IDE using whippersnappers.

zerokode.PNG

Well, for good or ill, Tibco GI is no longer the only IDE that eats its own dogfood. ZK has a visual designer called Zero Kode, an IDE written in ZK that allows you to visually design a ZK application. From part I of the tutorial that accompanies the IDE:

The visual editor is just a web application - packed in a '*.war' file' - that can be launched on an application server. It provides a visual interface with a toolkit that holds all the visual components that the ZK framework has implemented so far and is designed to use all kinds of custom components as well. This means that a developer can add to the toolkit components that he/she has designed, as far as they are compliant with the framework's protocol.

The developer drags-and-drops visual components on the active model, sets their properties (which are reflections of the corresponding Java class) and sets their events as well. Definitions of all the visual components found in the toolkit, are kept in an XML configuration file that can be edited by the developer in order to add, remove or re-order components. The developer can also load an existing '*.zul' file and modify it.

When run locally in an instance of Tomcat it's actually quite zippy. Still, you have to know your way around the ZK component heirarchy. Constructing tabbed panes and trees, for example, can be a bit of a pain. Some wizard functionality would be useful here. Also the property editor should probably be a part of a tabbed pane -- instead of a popup -- as you'll find in Eclipse or Visual Studio. (To be really useful, make sure to set the session timeout to a large value. There's nothing worse than having a design go puff because of a timeout.)

So, is it a toy or something useful? ZK zul files are pretty easy to write, which would argue for a verdict of toy, but I find the convenience of property and event handler editors quite useful. Altogether a promising start.


Technorati : , , ,

AjaxLoad - Not Ajax, But Useful

Now that we're operating from a single page interface and not depending on the postback to handle user response expectations with the spinning browser icon and the hourglass, we're rolling our own "pending" graphics. Along come AjaxLoad, a little application that will let you generate some animated "pending" gifs. radar.gif

ajaxload.info.png

Technorati : , ,

IDE Watch - Aptana

Aptana is a new IDE (embeded in Eclipse for now). If you already use Eclipse 3.2, you can just install the plugin from the update site: http://update.aptana.com/update/. Lots of good stuff: HTML, CSS, and Javascript code assist, etc. I've use it a bit and it seems likely to become a part of my development environment -- lots of productivity enhancements. Now I can write twice the number of social bookmarking sites as before. ;-)

The documentation is also very strong. Just check out all of the tutorials for using Aptana with various AJAX client frameworks:

  • Creating a new AJAX library project
  • Enabling Code Assist to work with AFLAX
  • Getting started with Aptana and AFLAX
  • Getting started with Aptana and Dojo
  • Getting started with Aptana and MochiKit
  • Getting started with Aptana and Prototype
  • Getting started with Aptana and Rico
  • Getting started with Aptana and script.aculo.us
  • Getting started with Aptana and Yahoo UI

None too shabby.



IDE Watch - Googlipse, GWT Eclipse Plugin

I'm working on some stuff to bring the GWT and other AJAX frameworks question -- "how can I write widgets for framework X in GWT?" -- full circle. In the meantime, I thought I'd point out two useful resources. First, GWT Site is a blog that tracks developments in the Google Web Toolkit world. If you don't have time to scan through the discusion forum every day, it's a good place to get your updates (other than here, of course ;-)).

One of the things that caught my eye, of course, was Googlipse, the so-new-its-still-wet Eclipse plugin for working with GWT. Regular readers of this blog will know that I've been working on my own Eclipse plugin for GWT, slated for release some time in 2010. After getting over my disappointment at being scooped, I decided to try it out.

The download is a simple jar that you add to your Eclipse 3.2 plugins directory. From the quickstart doc:

Googlipse is implemented as a WTP Facet. When creating a new Dynamic Web Project, select Googlipse in the Project Facets page. If you already have a Dynamic Web Project, you can add Googlipse facet by selecting Project->Properties->Project Facets(Please make sure you don't have gwt-user.jar in your classpath). In case you didn't like Googlipse, you can remove the facet.

[snip]

You can open the RemoteService interface and add/change methods in it. You need to provide the implementation of those methods in RemoteServiceImpl class, but thanks to Googlipse, you don't have to do anything in RemoteServiceAsync. Googlipse will automatically update the corresponding Async file whenever a RemoteService interface is changed.

The plugin simplifies creation of modules, creation of remote methods and handles launching and debugging in hosted mode. Since the your developing a a dynamic webapp, you can ship your GWT app in the end as a war. Best of all, it's Open Source.

Greasemonkey Tricks for AJAX Debugging

This is an old post that shows off a AJAX debugging tool written using Greasemonkey. It's still an interesting idea, but what is perhaps most useful is the long trail of comments that make reference to all sorts of other useful tools such as LiveHTTPHeaders.

Open Laszlo DHTML Milestone

Ever since Laszlo Systems announced that they would be targeting DHTML as well as Flash, I've been peeking into their source repository from time to time, hoping to catch a glimpse of the elusive "Legals" (horrible name), the runtime that supports DHTML. Well, this past Thursday, on the Open Laszlo Project blog, they announced a milestone release of this mythical beast. From the entry:


Late last week, the OpenLaszlo project reached a huge milestone: release of the first source snapshot of our multiple-runtimes architecture, code named "Legals". The purpose of this snapshot is to deliver infrastructure, tools, and architecture sufficient to allow broad community participation in the project.

We began Legals back in January because we felt it was finally time to invest in OpenLaszlo's potential as a multi-runtime application framework. Adobe had released an initial beta of Flash 9 (then called Flash 8.5), and it was clear to us that it would be essentially an entirely new VM: new bytecode set, many improvements to the ActionScript language, and substantially revised APIs. In order to support Flash 9 we would need to build a new compiler backend and new runtime libraries.


If you're viewing an lzx file from the OpenLaszlo server, you'll need to tack a parameter onto it to get it to display the DHTML, i.e. test.lzx?lzr=dhtml.

So far, I've only been able to get it to display two text components. Adding in a button or anything else gives you a big nothing. Definitely, as it says, a work in progress on the DHTML side.

The Hazards of Exposing Business Logic on the Client

Via Ajaxian we get an object lesson in the dangers of exposing business logic in the browser:

Beau Hartshorne of Snipshot (formerly Pixoh) says "massive chunks" of Cellsea code are identical to Snipshot. "This is not an accidental inspiration. Check out the cropping code, the resizing code, and so on. We've also noticed that portions of their website are also stolen directly from ours ... We are contributors to MochiKit open source project. However, the code in question is proprietary and was taken directly from out site."

Can I say "I told you so?" I've blogged about the danger of Ajax and Leaky Business Logic before. What is the danger here and the lesson the be learned?

  • Don't put your crown jewels in the browser. See if you can't lock a fair bit of your business logic on the server side by using a server-side component framework like Echo2 or ZK.
  • If you're going to deploy meaningful applications in Javascript, do what people have been doing with script source code for decades: obfuscate. You can do something simple like renaming all of your variable to one or two character names, or you can use a code generation framework like GWT or Morfik that produce unreadable code from the beginning. Be forewarned that code generators can be vulnerable to decompilers -- in short, if someone knows how GWT generates it's code, you could possibly reverse the process and produce the original source code.
  • Build in anti-theft mechanisms. This could be something as simple as a method that checks to see that the url the application is running on is the correct one, otherwise display a nasty message. You could make this as tricky and complicated as you like, all the way to encrypting big chunks of code with the website url and only decrypting them at runtime.
  • Hold out for "byte compiled" Javascript.

A combination of all of these may be what we end up with. I'm not sure I'd want to run any script in my browser, though, that I can't understand. Still, you would hate to be the victim of code-theft as has apparently happened to Snipshot.

How similar are these two programs? Well, Cellsea offers a bunch more functions, but they do look very similar, both in terms of the UI and the underlying code. The original Snipshot is here and the knock off here. You be the judge.

If you are really hungry for a good AJAX image editing app, the best of the bunch of them may be Phixr, which gives you preview, the ability to marquee select for certain operations, etc. Slick, even if the UI is a bit jumpy.

phixr.jpg



An Interview with ZK Creator Tom Yeh

Anyone who has been following the development of AJAX frameworks has heard of ZK, the server-side component GUI framework that allows you to write applications like you would a desktop app. It has become one of the most popular projects on sourceforge and has been nominated for a 2006 Sourceforge.net Community Choice Award.

Recently I talked with one of ZK's creators, Tom Yeh of Potix, about the Framework's popularity and future.

ZK Background

DK: How did you come up with the idea for ZK, i.e. an AJAX framework that allows you to write webapps like you would a desktop app?

TY: As I mentioned in http://zk1.sourceforge.net/faq.html#Why, it is the result of frustration.

I was a fan of thin-client computing since leading a wonderful team to develop Network Computer and Window Terminal in 1995. I truly believe in the so-called utility computing. Accessing applications should be as simple as using tap water.

It is crazy that someone should carry tons of water when traveling, since tap water is available everywhere. However, we still travel with notebooks, even though Internet connectivity is everywhere. Similarly, the Web edition of MS Outlook has been available for years, but we are still using the desktop version. Why? Frustrated user experiences and excessive development costs. In other words, it is too costly to develop a Web UI from scratch or add-on to 'legacy' apps, and people won't use the Web UI even if it is provided.

After trying different ways to apply Ajax in the projects on which we consulted, we found that applying Ajax at the client side, as most frameworks did, only solved the half of the problem -- though it did result in a lovely interface. That is why ZK was born.

DK: Who is Potix?

TY: Potix is a consulting firm providing expertise in Web development and project management. We also develop applications on an ODM-basis. ZK is the consequence of this work. However, due to strong demand, we mainly focus on ZK now.

Potix is also a house of old dogs. Most of us have more than 15 year of experience, ranging from developing Windows/Linux/Web applications, to embedded OS and GUI frameworks. ZK is my second OSS project; the first one, called OpenPam (GUI for embedded devices), was not very popular.

DK: How are you planning on making money with ZK? Nextapp, the makers of Echo2, sells an Eclipse plugin for around $400. Is that a business model you are examining?

TY: Dual license (as MySQL did). You might also take a look at one of my posts: http://sourceforge.net/forum/message.php?msg_id=3605162


Other Frameworks

DK: Echo2 seems to be the only other server-side AJAX framework out there. How would you compare yourself with Echo2?

TY: Echo2 assumes UI designers are Swing programmers, while ZK assumes many of them are not programmers.

Markup languages, like HTML, XUL and XAML, scripting languages, like PHP and Ruby, and the object oriented approach are the three most important developments since GUI was introduced. Unfortunately, Echo2, WebOnSwing and similar frameworks only focus on the object-oriented approach.

In addition to BeanShell, we are looking at the possibility of using Ruby and PHP in zscript. It looks to be, so far, quite feasible.

DK: There's lots of talk now about the Google Web Toolkit. Do you see it as a competitor to ZK or a complement?

TY: Both.

From a technological viewpoint, it is a complement. GWT is a client-side solution and quite good for developing Ajax components. On the other hand, it is never a good idea to replicate the business logic to the client, which eventually brings us back to the maintenance headache of fat clients. In addition, loading huge JavaScript files into the client and executing them there is not fun at all. At the end, you need a server-side solution to handle the business logic and pre