Monday, May 11, 2009

jQuery in RichFaces

It's a glorious day! jQuery (my absolutely favorite JavaScript framework) is part of RichFaces! I just found that out.

Well, my happiness didn't last very long. As soon as I realized that it's backed into richfaces-impl jar and that it's an ancient version my lucky day become a nightmare.

RichFaces just have to play nice with everyone, they just can't live without everyone on board. So we have Prototype (a very good library btw) that makes heavy use of the $ sign, then we have jQuery (same thing) and Scriptaculous (obviously).
Did any of the designers of RichFaces ever thought that I might personally dislike the mess they are introducing with this many libraries?

And btw - the ancient jQuery is still ok - but the nice $("#output").dosomething() syntax is gone since jQuery is the one that has to play nice with the rest. That is just not fair! Imagine fixing every single plugin you're trying to use with jQuery to use the full name instead of the dollar sign. Imagine upgrading a set of such plugins... Cool, ain't it?

I've heard that in the latest beta version of RichFaces they have upgraded jQuery to 1.3.2. Let's see if they'll be able to keep up with the latest release once they go GA.

4 comments:

  1. I wanted to know one thing. Is it possible to use jQuery in a JSF application. If possible, then how? Please share.

    ReplyDelete
  2. It is possible - when you're using jQuery in "compatibility mode" (so no $ function but instead just the plain old jQuery function) and it only works to the extent that you might be able to manipulate the DOM objects but I'd be careful with the DOM tree. No Ajax, no fun, no nothing.

    My boss says it's because we don't want to code in JavaScript - which is in my humble opinion plain crazy when we're talking about doing browser-based applications... But that's me and I'm known to be wrong.

    So at the end of the day JSF users are just crippled by the fact that the client side is so very much closed to them.

    ReplyDelete
  3. I can get RichFaces & jQuery to work really well... on the first page load - but what about making subsequent RF ajax requests? None of the jQuery code works after part of the page has been refreshed by ajax. Ugh, I hate this crap.

    ReplyDelete
  4. The truth of the matter is that if you want to make an Ajax call in JSF in general (and RichFaces is no different in this regard) you have to use whatever JSF provides for this, or else!

    This is due to the fact that JSF needs to spin off the whole page life cycle, then to create the whole page in response and on the client to extract the part that needs updating and to put it into the destination element.

    To my taste it is more like Ajah than Ajax but nobody wants to hear that name as it doesn't roll out the thong nicely :)

    ReplyDelete