webtier@glassfish.java.net

Re: JSF 2.0: Errors or Ambiguity in Spec for "onevent" JavaScript Callback

From: <webtier_at_javadesktop.org>
Date: Thu, 01 Oct 2009 04:21:31 PDT

> [...]
> So I far prefer:
>
> var namespace = {};
> namespace.functionName = function functionName(param,param) { };
> [...]
> 'Sides, function functionName() is just going to
> pollute your global namespace anyway, and we don't
> want that.

Aha! I finally discovered my fundamental misunderstanding about all of this. I thought that
[b]foo.bar = function bar(...) {...};[/b]
was equivalent to
[b]function bar(...) {...};
foo.bar = bar;[/b]
That is, I thought that the top form created a global function called bar and then assigned it to the bar property. So, in my incorrect understanding, they [i]both [/i]would have polluted the global namespace. Shows how little I really know about JavaScript! (Of course, the same could be said for Java. :-) ) Thanks for clueing me in.

> We made a conscious choice to make the JSF JS code
> not extend any object prototypes because we want to
> be able to be used with any library out there, BTW.
> Same thing with namespacing everything.

Yes, I had noticed that, and I think this is a great thing and very well thought out. Am I correct in interpreting Section 13.2 as saying how an implementation [i]could [/i]use Open Ajax, not that implementations [i]should [/i]use Open Ajax? My look at the code suggests that Mojarra is not using Open Ajax, correct?

Thanks again for patiently explaining the var foo.bar = function bar(..) {...}; business until I [i]finally [/i]got the point.

Cheers-

- Marty
http://www.coreservlets.com
[Message sent by forum member 'martyhall' (hall_at_coreservlets.com)]

http://forums.java.net/jive/thread.jspa?messageID=366468