Adam Bien's Weblog

Wednesday Apr 10, 2013

Which Java Web Framework To Choose? The Client- vs. Server-Centric Story

Web frameworks are sometimes compared using their components and L&F as main criteria. Visual appeal as a differentiator, however, is not critical for productivity. Before you are going to look at the components, you should rather more deeply think about the user interactions.

In case your application consists of a set of wizard-like forms (page flow) with validated input fields, data binding and server side validation will increase your productivity and reduce the complexity of the application.

On the other hand, office-like applications with longer "offline" periods do not require fine grained interactions with the server and can live entirely at the client side.

Client-centric web frameworks are covering the latter case. With web frameworks like GWT you don't even have to interact with the server. Your entire code is translated into JavaScript and lives self-contained in the browser. With GWT it is very convenient to build one-page, offline, office-like applications with only little communication with the server required. zkoss follows similar architecture, but supports data binding and is so server-centric as well. Because a client-centric framework is entirely executed on the client it should not consume any resources (CPU / memory) on the server.

Server-centric frameworks keep a component UI tree on the server. The state of input fields and UI components are synchronized with the server side representation for your. Usually you get data binding for free and can easily perform server side validations as well as, access any backend services. Serverside validation is implemented in Java and is easier unit testable. In addition, client side validation can be implemented to avoid server round trips.

The strength of the server-centric frameworks is built-in fine grained data binding and server side validation as well as conditional page flow. Naturally a server side framework is less convenient to build offline, office like applications with a considerable amount of client code. JavaServer Faces, Wicket, Tapestry, Vaadin are some examples for server side frameworks.

Because a server-centric framework is going to be executed on the server, it will consume a considerable amount of CPU and memory.

Using GWT for a form-based wizard with lots of server side validation will require you to write some RPC code, and for the implementation of an offline single-page HTML 5 application you will have to write a considerable amount of JavaScript. Both approaches are doable, but why? :-)

See you at Java EE UI Workshop at MUC Airport!


NEW: Java EE 7 Testing and Quality Workshop

A book about rethinking Java EE Patterns

Comments:

whart about half-objects (like eclipse.org/rap/)

Posted by Rainer on April 10, 2013 at 03:51 PM CEST #

To zkoss is more similar to Vaadin than GWT, it's a Server-centric framework.

Posted by Gérald on April 10, 2013 at 05:55 PM CEST #

Whats your opinion regarding Struts2 framework or Play

Posted by Dimitri on April 10, 2013 at 06:23 PM CEST #

Adam,

Have you taken a look at Errai? It's built on top of GWT and provides CDI injection on the client side and even CDI event support (events can be seamless transferred from server to client and vice versa). It's mostly seamless and you can even inject an EJB Remote interface into your client code to call EJBs on the server.

For any project using EJB/CDI server-side it looks like Errai is the best fit.

Corey

Posted by Yeroc on April 11, 2013 at 12:47 AM CEST #

If you want a client-centric web framework go with AngularJS with RESTful web services and forget about GWT.

You should definitively also include Stripes Framework (and probably others action-based frameworks) in your server-centric framework's list.

Posted by Samuel Santos on April 11, 2013 at 04:22 AM CEST #

I would like to hear your opinion about Struts 2 and where you see it fit. I've used Struts for its MVC as well JSF for its components and how it works well with other Java EE technologies. The fact is Struts' MVC is really powerful and useful for content centric for example online stores and allows you to have a good control over the html code generated. I always wonder why there is no standard MVC framework like Struts in Java EE or why Struts was not made a standard in Java EE.

Posted by Samad Atoro on April 11, 2013 at 08:01 AM CEST #

I agree with Samuel, using backbone.js and some UIFrameworks like boostrap is fancy and quickly.

And consume less memory (it's an issue, we have application based on JSF 1.2, with among 2000 concurrent users online ( and a total of 6000 users) and the amount of memory used by JSF to render the tree, for every user is high, so it goes on high gc pauses or adding more servers to the clusters.

I believe that with HTML5, UI Interfaces have to move to client.

Posted by mart dominguez on April 12, 2013 at 06:02 PM CEST #

@mart Can't believe someone is still using JSF 1.2. JSF 2.0 came out 4 years ago and the current version is 2.2. A lot of things have changed since then. Concept remains the same however... But still, I think that 2.0 performs better than previous versions.

@adam, thanks for this short overview. I'd also like to hear your opinion on Struts 2.

Posted by Anton on April 21, 2013 at 01:44 AM CEST #

Anton, i've just red your answer today.

It's a large project, so we are in a migration proccess, but it's so complicated.

Some modules we are using JSF 2.0.

But isn't easy to migrate, specially when yo use some Frameworks, (richfaces + hibernate). The are a lot of issues in your code, and many things are broken. But we are in proccess.

Posted by mart dominguez on June 24, 2013 at 06:29 PM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
realworldpatterns.com
...the last 150 posts
...the last 10 comments
Links
License