Monday, May 11, 2009

Colose encounters with J2EE/JSF

Hi,

One of the projects I work on involves heavy JSF usage. Along with other tools to make our life "easier" (Facelets for example) the project runs quite smoothly. Right up to the point where a little bit more "custom" solution is required...

Here's the problem: I need to call a method that will return some JSON that will be evaluated by the client and according to the result of this operation some action must be taken.

As long as I wanted to use the rather limited XMLHttpRequest capabilities provided by Ajax4JSF I was fine. Now I need a little bit more control and flexibility over the actual flow and I am screwed. I'm not really interested in the whole life-cycle of a JSF page and all that statefull crap JSF provides - all I need is a simple call to a method and return a little bit of text - that's all.'

As it turns out there's no such thing in JSF directly. There's however a big honky machine to actually hide the inner-workings of JavaScript from an evil developer like me. I can almost hear the creators of Ajax4JSF saying "no no.. that's not allowed here, nigther is that, and oh that's because of X and that's because of Y and that's because it is like that, period". I'm sick and tired of this miserable framework.

So far I've not found a single thing that I like about JSF (MyFaces and RichFaces in particular). To start a project it's a configuration nightmare (if you want to have more than one JSF component library like RichFaces and Tomahawk), some things are simply incompatible. RichFaces force me to use stone-age version of jQuery (my favorite and better with each release), mix things that don't really come together (like server-side code being "executed" by so called "client actions" for example). The whole beautiful stateless nature of the web is gone with the wind in the worst possible style. And last but definitely not least: there's no control whatsoever over the generated markup, nada, zipp, null... And let me tell you, it's huge!

Apparently the designers of RichFaces (and other JSF-related frameworks) didn't follow the news and in their urge to "define" every damn thing they have forgotten that it actually matters in what way you define the layouts. Doing it with multi-level tables is probably the worst thing ever about the generated HTML, but it's definitely not the only horror you'll see. Constant 'styles' and 'script' blocks, intrusive JavaScript and the like are just standard. How can something so bad have become so popular? Oh I get it: scriptlets are the source of all evil in the enterprise application world... How could I forget that mantra. Apparently URLs are also evil as they have no damn meaning in JSF. Posting a form (or however its called in the JSF world) reveals the concept of ghost-urls: you're seeing the next page but the URL didn't get the memo yet. Whatta heck???

No wonder that MVC-based solutions (Spring MVC, ASP.NET MVC, Rails, Django) are getting more and more popular. Those are actually non-hammer tools to get the job done without 100-line exception messages getting in a way.

And don't get me wrong: I'm sure JSF is good for something - it just so happens it's not the creation of highly interactive, flexible and customizable Web 2.0-enabled enterprise applications.

"Close encounters my a..." - John Criton / Farscape.

1 comment:

Unknown said...

JSF is popular because of only one thing - it is a substandard of JEE platform and is mandatory on any JEE-compatible java web container.
When people learn JEE they learn JSF and... they are doomed, because they want to use STANDARDS (and managers love standards)