JSF rocks

Leave a comment

June 7, 2010 by huionn

I spent this weekend learning JSF (in the context of JBoss Seam, Facelets and RichFaces). I would say the experience is enjoyable because I like JSF’s paradigm. In particular, JSF Unified Expression Language backed with managed beans is intuitive to use for server-side programming. I don’t know about how expensive is EL processing, but its data binding greatly simplifies the web development. The example below is based on JBoss EL enhancement.

<h:dataTable value="#{order.items}" var="item">
    <h:column>
        <h:outputText value="#{item.name}" />
    </h:column>
    <h:column>
        <h:commandLink value="Cancel" action="#{order.cancel(item)}" />
    </h:column>
</h:dataTable

When the link is clicked on the browser, the method cancel(Item) of managed bean order will be invoked on the server side with the item in the selected row as parameter. No boilerplate code is required. No row index calculation. No id searching. It is simple to code and easy to understand.

I have read many blogs, forums and web pages about “JSF sucks”. However this is not true for me. For me, JSF is most suitable for creating a rich web interface with JSF component libraries such as RichFaces (as demo in http://liferay.exadel.com/web/guest). It makes AJAX rich components deceivingly easy (although thorough understanding of JSF concepts are still required to apply them effectively). I have used dojo for rich UI before, but synchronizing client states with server state is tricky for me. For RichFaces, the client side changes are applied to server state (managed beans) through AJAX and the response is rendered from updated server state to client AUTOMATICALLY.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: