Comments on the Ajax code.

From: Jim Driscoll <Jim.Driscoll_at_Sun.COM>
Date: Tue, 02 Sep 2008 17:33:19 -0700

Some comments on the Ajax code. Some of this requires a bit of writing,
so I wanted to run it by the group before I made a change.

Roger, I'm especially interested in your input.

I'm still getting my head around the Javascript code, so there may be
somethings I don't understand correctly.

In AjaxEngine, we define a global, observer.

It's a bad practice to define a global in general - I think we should
resolve not to do this in any of our code... It's especially bad to
define a global with a common name in a widely shared library.
Similarly, the functions in Observer require overriding the Array
prototypes - which is again bad practice in a library.

We'll have to fix this, before ship, I think. I'm loath to just do it
since it will have an API impact. If you want me to just do it and
report back, let me know.

Also, though we register ourselves with the OpenAjax library, we don't
actually use the pub/sub hub. We should, I think, plan to, as part of
the Observer object.

We also create a global queue object, with similarly fraught
consequences. We'll have to change it.

Since these are supposed to be singletons, I propose that we just use
the existing objects instead of creating new ones at the global level.
The downside of this is that people will have to get used to typing
javax.faces.AjaxEngine.Observer instead of just observer...

For error handling, I'm just going to add a bunch of throws Error stuff
in there, with custom names, rather than creating new error types.
I'll also add the errors thrown to the documentation.

What this means:

We'll do things like throwing an object of type Error, with name
"NotFound", and message "Referenced object" + id +" not found". There
are other ways to do this, such as defining a bunch of custom errors in
our namespace, but that seems to be overkill, as well as cluttering up
our namespace with a bunch of objects that people really don't need to
care about very much.

I'll do this without waiting to hear back, since this one seems fairly