JSF is not what you’ve been told anymore

Thoughtworks Technology Radar 2014 has made an “outdated” analysis on JSF with focusing on the abstraction of HTML-CSS-JS which is against modern web development. Notice they use the term “J2EE” that explains a lot already about their research.

The analysis has two major problems, JSF is not what they have been told anymore and second “We recommend teams use simple frameworks and embrace and understand web technologies including HTTP, HTML and CSS.” assumes there is a silver bullet in web frameworks where there is none, but there is a silver bullet for each project type. Things can get really messy for complex form oriented web applications with tons of javascript and css, JSF handles the heavy lifting here. I’m not saying you don’t need to know these technologies, it will be great to have this skill set so that you can tweak things around, it is just working with them directly has a bad impact on productivity and project deadlines. This comes from a team who makes a living with writing javascript, css and html. Regarding state, JSF is a stateful framework by nature and state makes web applications easy to develop with. With improved state management techniques introduced in JSF 2.0+ (e.g. stateless mode, partial state saving), JSF can scale as well.

Back to the analysis, it is not valid because it mentions improvements in JSF 2.0 without knowing JSF 2.2 is out for sometime with killer features catching up with so called modern web development (the one where you write your own javascript, css, ajax, html). Also the analysis claim that JSF is chosen because it is standard, remember what happened to EJB 2.x and why non-standard Spring got popular? Similarly, JSF 2.2 compared to 1.0, is what EJB 3.x to 2.x. Still haunted by bad initial reputation and hated by a group who doesn’t like it because it is standard and their favorite framework is not.

Best way to show how powerful JSF is with an example, following page makes use of bootstrap for css and regular html elements considered as JSF components. Plus we have a PrimeFaces messages and ajax update for messages.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:jsf="http://xmlns.jcp.org/jsf"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
            xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>User Page</title>
        <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet"></link>
    </h:head>
    <h:body style="padding:20px">

        <form jsf:id="userform">

            <p:messages id="msg" showDetail="true" closable="true" />

            <div class="form-group">
                <label for="firstname">Firstname</label>
                <input id="firstname" type="text" class="form-control" placeholder="Enter firstname" jsf:value="#{userView.user.firstname}" />
            </div>
            <div class="form-group">
                <label for="lastname">Lastname</label>
                <input id="lastname" type="text" class="form-control" placeholder="Enter lastname" jsf:value="#{userView.user.lastname}" />
            </div>
            <div class="form-group">
                <label for="email">Email address</label>
                <input id="email" type="email" class="form-control" placeholder="Enter email" jsf:value="#{userView.user.email}" />
            </div>
            <button type="Submit" class="btn btn-default btn-primary" jsf:actionListener="#{userView.save}">
                Submit
                <f:ajax execute="@form" render="msg" />
            </button>
        </form>
    </h:body>
</html>

Page author is not abstracted from HTML, CSS and Javascript at all. When used like this, JSF does the heavy lifting on backend with value retrieval, validation, conversion, model update, actions and so on except rendering. That is up to the page author. When using a javascript mvc framework like angularjs, knockouts or *js, you need to bind the UI with a server backend using javascript calls, here JSF provides the integration out of the box. Note that, you can use these *js frameworks with JSF as well if you want.

Summary
JSF has been around for 10 years, if it was a bad framework, it will easily get lost in the jungle of web frameworks of Java. Various frameworks has reached their technology peek during past 10 years and started to fade away already. In JSF case, First Facelets saved it, JSF 2.0 fixed it along with JSF 2.2 and then PrimeFaces has given it a popularity boost. Clearly it solves a problem better than others which is creating web applications with an easy, efficient and productive way to meet deadlines. With JSF 2.2, using HTML friendly markup and pass through attributes it caught up with latest trends as well. Add PrimeFaces on top of your stack and get a productivity boost.

Haters gonna hate :)

This entry was posted in JSF. Bookmark the permalink.

11 thoughts on “JSF is not what you’ve been told anymore

  1. Well said Prime, well said..

    I’am well awared too, that JSF + Primefaces will be getting more poppular and efficient for us -developers-who-must-create-a-lot-a–complex-form. Especially for enterprise scale projects.

    I’ll always bet on Primefaces!

  2. I totally agree with your assessment! I’ve been working with JSF since 2005 and I still use it everyday. With 2.2 I can hardly find anything to complain about. I really love the component oriented way of doing things. It keeps things nice and tidy!

    Thanks to Primefaces for making my days even easier!

  3. It is great
    but if I add an external css.
    this will cause the page load perform other because not only load external css, if not also the css of Primefaces.

    Each of us need to build your CSS, without relying on Primefaces even that people have come to rely on these alone and not learn CSS on your own.

  4. I agree with the article 100%. The real advantage comes from frameworks like PrimeFaces that blend the back-end power of JSF with client side technologies like JavaScript, HTML5 and CSS. That is truly where the power lies. I am so glad that PrimeFaces is around. The CRUD Generator I am maintaining would have been very hard to implement would I have to write out all the JavaScript and AJAX hooks myself. And that is all form-based. You know, just mentioning the outdated JSF 2.0 shows that this analysis can’t be given a lot of credibility.
    Go PrimeFaces!

  5. Totally agree
    Once upon a time when you work only with JSP and Servlets, I can remember the era in which.. looking for a framework to improve efficiency you needed to use fw like struts… and then JSF come with us… my first big custom component was a paginator… after this with JSF 2 and 2.2 all change with beauty fw like Primefaces… I can’t understand how can be better to work with html, css, xml ??? just not efficient….

  6. Anyone who still talks about J2EE obviously don’t know what they are talking about. Even recruitment agencies in London have stopped using that acronym.

  7. I think the author of the article on thoughtworks is newbie in JSF. Not JSF tries to abstract away HTML, CSS and HTTP, but GWT, Wicket and Co. who are trying to code the web in Java. It’s not natural and can’t really have an success. Also Flex, JavaFX and Co., who require browser plugins, don’t follow a natural way of web programming.

  8. A well written response … As Gavin King said a few years ago (paraphrasing): “it is 2011, we shouldn’t be using request/response based applications anymore.” JSF 2.1/2.2 and Primefaces makes that realization possible. Thank you making my development easier and more fun.

  9. Very good explanation Cagatay. I will recommend this article to read everybody Who hates JSF technology without knowing its power and flexibility. JSF is not for abstracting the client side technologies but a complete framework with powerful life cycle(from create view stage to render/output view stage) to ease the web application task in a quick time.

    No product is willing to spend their years of time working with the HTML,CSS,JS,Conversions,validations,event handlers on their own. JSF+Primefaces will do everything for you in a quick time with stunning widgets.We still have full control on the client side technologies by using new passthrough attributes,extending the renderers, widget js files,custom CSS files where it required.

    Anyhow we don’t need to think much about one article who written without knowing about that technology fully.

  10. From an academic- or a tech-fetish perspective it might be good to use plain javascript/css/html. In practice, when it comes to running real projects, speed of development, ‘error-freeness’ and getting things right the first time are so much more important than if one fully understands what the page source markup looks like… In my opinion, every new like of home-written javascript is a potential bug and I better bet on Prime than on homegrown ajax technology…