Laurie Harper wrote:
Joe Germuska wrote:
[...]
I would recommend against using Prototype[3] or JSON[4] with Struts,
as they use a JavaScript strategy which is incompatible with
commons-validator and the html:javascript tag (see Bug #37134[5]).
[...]
[5] http://issues.apache.org/bugzilla/show_bug.cgi?id=37134
I just tried it, and prototype+validator works fine for me. It's
possible my test just didn't use the particular combination of features
that provokes the problem, but I believe what's going on is actually
that the problem has been resolved in prototype.
Well, yes and no. The specific problem that caused issues with Validator
has been fixed, but most of the other issues remain. For example:
1) It messes with fundamental JavaScript types. This was the source of
the problem with Validator; that specific case was fixed, but many more
remain. Take the following function:
function countProperties(o) {
var c = 0
for (p in o) { c++; }
return c;
}
Now invoke that:
var count = countProperties(new String(""));
Without Prototype, the result is 0, as you would expect; with Prototype
1.4.0_rc2, the result is 8. Now, the above is a contrived example, but
to have fundamental types like String and Function changed underneath
you is very dangerous.
Obviously many people don't think that's an issue for their own apps,
otherwise they wouldn't be using Prototype (or else they just aren't
aware of the issue yet). But think about what's going to happen when
Prototype gets pulled into a portlet and messes up all the other
portlets on the same page. And if that was *your* portlet that messed
things up, you're not going to be very popular. ;-)
2) Prototype is not namespaced. It splats a significant number of
objects into the global namespace. That means it doesn't play well with
others, to say the least. To make sure you don't mess up Prototype
yourself, you need to know which objects Prototype defines. And if you
happen to define something as a global (which you wouldn't, of course,
because you're smarter than that - you're a Struts user, after all ;)
that's not in the version of Prototype that you're using today, but they
add it in the next release, well you're probably hosed. Also, the
portlet scenario raises its head again here. If other portlets on the
same page define globals with the same name as Prototype, something's
going to be broken - and you don't want it to be your fault. ;-)
Note that, sadly, these issues also apply to libraries built on top of
Prototype, such as Rico and script.aculo.us.
If I'm right, we could close #37134 (perhaps adding a note as to which
version of protoype fixed the problem it describes). If you can still
demonstrate the issue with current versions of prototype I'd like to
know how, as I have a bunch of prototype-based Javascript I was planning
to use in my Struts app... :-(
I haven't tried it, but it does look like the 1.4 release of Prototype
has fixed the most egregious bug, meaning that it would work with
Validator. If Prototype continues to develop in the same manner, though,
we can't guarantee that Validator will continue to work with later versions.
--
Martin Cooper
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]