MVC Frameworks for GWT: A Brief Survey

gwtOne of the more difficult aspects of using the Google Web Toolkit for enterprise development is its lack of a framework.  This is by design: GWT is a toolkit, not a framework.  It doesn’t tie you into a single approach or methodology, it lets you use any you like.

That freedom is both a blessing and a curse.  You don’t have to learn a new model or way of doing things… because GWT doesn’t give you one.  This is especially true of the Model-View-Controller (MVC) pattern, which I was introduced to when learning AWT and Swing programming for Java.  There are a number of third party projects which step up to provide an MVC framework for GWT; some have been around a while, others are newcomers to the scene.

Gwittir appears to be the most mature; it also has the most confusing name.  (I originally thought it was a GWT interface to Twitter.  It isn’t.)  The Gwittir team provides ample documentation and even a “Gwittir Way.”  Gwittir is heavier than the other MVC projects, but I suspect that if you follow the Gwitter Way you’ll be saved the trouble of implementing a lot of common components yourself.

GWTruts draws its inspiration from Struts, offering dependancy injection and providing MVC configured via XML configuration files.  If you find XML to be a comfortable way to define a user interface, you should look into this package.

The package which had the greatest influence on our internal GWT MVC efforts was the GXT MVC package.  It has the least documentation — although there is this javalobby article — and appears to exist only to support the GXT widget examples at this point.  We’re using the GXT widget library and I admit that I discovered the GXT MVC package purely by accident — but it provided a good, easily understandable lightweight MVC approach.  You need to fill in much of the code if you use this as your framework; it’s nowhere near as fully featured as the other projects listed here.

The GWT-MVC project is the lightest of the standalone MVC frameworks.  It’s a step above the GXT MVC package in terms of heaviness, but like that framework it requires you to fill in much of the implementation yourself.  There’s something to be said for this approach, as it doesn’t tie you to project-specific configuration and APIs so much as give you a leg up on developing your internal framework.

The Google Web Toolkit is a great contribution to the web development world, as it makes developing and deploying rich internet apps much easier for Java enterprise shops.  Thanks to contributions from a number a projects we’re seeing progress in the MVC framework space, and there are a number of interesting options to choose from out there.

Update: I just became aware of mvc4g, another Struts-inspired, xml-driven MVC framework.  Did I mention there was a lot of activity in this area?

Update: Changed the GWTruts section so it no longer gives the impression it’s only for small apps; per the comments I’ve recieved it sounds like it scales quite well to large apps as well.

11 Responses to “MVC Frameworks for GWT: A Brief Survey”

  1. Reza Says:

    Hi,
    I am the author of GWTruts and I am happy to see you have mentioned it here.
    In this post you said that GWTruts is only good for small application.

    We have already use GWTruts in big applications and if you want I can discuss it is possibilities more.

    You have my email so please write back to me if you want.

  2. Jim Says:

    My attitude toward Struts colored my impression of GWTruts somewhat. With thousands of JSPs in our application one argument we had against Struts was the need to maintain the single XML configuration file; this approach was deemed, rightly or wrongly, to be too much overhead for our use at the time.

    Seeing mention of an XML configuration file in GWTruts brought back memories of those arguments, hence my suggestion that it might be better for smaller projects. I haven’t given much thought to the fact that GWT projects are architected completely differently from our JSP solution and that the single configuration file approach used in GWTruts may not be an impediment to maintaining a large code base.

  3. Reza Says:

    Hi Jim,

    There is an option that you can have more than one configuration file for GWTruts.

    Having only 1 configuration file was a problem that we faced in early versions, it lead to one single big .js file for the whole project.

    In version 0.8 now we can define configuration files per GWT module.
    It makes xml files smaller and grouped logically, it also generates smaller more task oriented javascript files.

  4. Julian Says:

    You need to checkout SmartGWT

    http://www.smartclient.com/smargwt

    Read about it’s data binding model…

  5. Julian Says:

    Sorry the link was bad:

    http://www.smartclient.com/smartgwt/

    and

    smartclient.com/smartgwt/showcase/

  6. Jim Says:

    There’s an updated list in this blog post:
    http://supplychaintechnology.wordpress.com/2009/05/07/more-mvc-for-gwt/

  7. GWT Atchitecture anyone? « TechnoBuzz Says:

    [...] Another interesting thing is the difference  toolkit vs framework [...]

  8. Richard Sullivan Says:

    Anybody using PureMVC ?
    see
    http://trac.puremvc.org/PureMVC_Java_MultiCore
    and http://trac.puremvc.org/Demo_Java_MultiCore_GWT_EmployeeAdmin

    I’m a GWT newbie also looking for an MVC framework.
    Thanks,
    Richard

  9. Jim Says:

    PureMVC is listed in the updated list here: http://technology.gtnexus.com/2009/05/07/more-mvc-for-gwt/

    …but I can’t speak to usage.

    You might want to look at Ray Ryan’s Google IO presentation on Best Practices (http://code.google.com/events/io/sessions/GoogleWebToolkitBestPractices.html) and search for the latest discussions on MVP projects for GWT.

  10. The Code-House Blog » GWT oraz implementacje MVC Says:

    [...] W kwietniu 2009 pojawiło się pierwsze zestawienie implementacji MVC na blogu Supply Chain Technology [...]

  11. A View Back, and Looking Forward « Supply Chain Technology Says:

    [...] traffic picked up substantially when one of our GTN-MVC posts was picked up by a GWT news aggregator, and our GWT posts remain among the most popular we’ve [...]

Leave a Reply