users@javaee-spec.java.net

[javaee-spec users] Re: [JAX-RS vs JSF] Why having two web app frameworks is not a bad thing

From: Adam Walczak <me_at_adamwalczak.info>
Date: Tue, 18 Dec 2012 01:55:01 +0100

Hello,

For starters I would just like to note that "possible" isn't good enough.
When I'm choosing a tool to fit my requirements then I want something that
will make implementing them easier, not just possible.

*(Maybe I know too little about JSF and how to use it, but I also knew
little about JAX-RS and Jersey MVC which was straight forward both when
examining its documentation and later in development)*

*Handling URLs for SEO, bookmarks and readability*

The three first points have one related issue. The fact that JSF tries to
hide full URL's and HTTP from you. Yes I know I can use Filters and
PrettyFaces but its like using mode_rewire for a badly written PHP
framework. It's just boiler code to correct bad URLs that I didn't want in
the first place. PrettyFaces it self has plenty of issues with components
in various JSF toolkits. It's not a pain free solution.

PS. Correct me if I'm wrong but as I heard this makes the same page
available at two URLs.
If the SE crawler finds the two URLs in my HTML code then I'll get
a penalty for dual content.

Another funny thing is that there are whole articles how to make nice
bookmarkable URLs in JSF 2 that the SE crawler and users can use. WHOLE
ARTICLES ! This is madness and really should not be so hard.

To make good SEO you have to pack keywords into URLs and do content
layering. JAX-RS helps you big time with this. Doing it in JSF is just
unproductive and unmaintainable in my opinion.

Besides you also have to know some HTTP concepts to maintain a site. Like
using HTTP redirects with 301 code when you change an URL of a page.
Without this you will loose your previous SEO effort.

*Working with pure front-end devs*

JSF has one great plus for me. If you have a team composed of mainly Java
devs then JSF can hide many of the complexities of managing
HTML/CSS/JS/HTTP. It just lets you write a GUI that runs in the browser.
It's a great advantage.

But this does not work the other way around. Pure front-end devs hate
JSF/Facelets. They hate Java to be more precise. You just cannot force them
to do JSF components effectively. For them this is madness. They have
jQuery and good HTML/CSS/HTTP skills and we want to abstract it all out to
expose a Java API. It's just abstraction over abstraction that adds nothing
for them. Worse ! it adds complexity and gives you another API to learn.
Mashups are a pain to do this way.

It's much better to just give them and simple template language and HTTP
end points. And you can do exactly that with JAX-RS MVC. They
will understand it and be happy. They don't even have to know that Java
runs the back end.

PS. With Jersey's WADL file you can even auto generate the documentation
for the endpoints.

-- 
Adam Walczak
www.adamwalczak.info
+48 604 188 992