Tuesday, August 25th, 2009
Be your company MVP with GWT!
<p>Sorry about the cheesy title, I couldn’t resist. In one of those moods I guess. Chris Lowe has posted a detailed example of a new-age GWT application that uses lots of cool tech based on Ray Ryans talk on MVP pattern;Chris takes these ideas and applies them to the starter project created by the Google plugin for Eclipse. To get this done, he uses a slew of libraries:
| GWT-Presenter | An implementation of the MVP pattern; |
| GWT-Dispatch | An implementation of the command pattern; |
| Google Gin | Dependency Injection based on Google’s Guice; |
| GWT-Log | A log4j-style logger for GWT. |
NOTE: currently GIN needs to be built from source using SVN/Ant.
You’ll also need the following libraries at the server:
| log4j | A logging framework; |
| Google Guice 2.0 | A dependency injection framework for Java. |
Then, the tutorial walks you through setting up your views, presenters, and events. It is Java, so you will notice a fair amount of source code (but at least the GuiceServlet gets rid of most of the XML). Just joshing with ya!
It was cool to see my buddy Rob’s Customware being the place that created some of the key libraries. Good on ya mate!
Related Content:











Small post bug: The Google Code MVP-link is missing a ” in the anchor tag.
Good god what a mess, do people really develop stuff this way?
That article should get an award for the most over engineered, code extensive Hello World example ever made. No thanks, I’ll stick to JSP and AJAX.
I couldn’t agree more with Stakka, this piece of code is just a gas factory and making an hello world example of it was definitely a bad idea…
Lol, fail.
GWT is great but I’m still confused of MVP concept
visit: ecofe.blogspot.com
I just watched the presentation and read the article and had to sign up here just to agree with Stakka and Darkimmortal: hello world fail, lol
@Critics: This is not a “HelloWorld”-Sample, this is supposed to be an example for writing HUGE GWT applications á la Google Wave.
If you measure by “HelloWorld”-standards, even Rails is overkill for their famous 15-minute-blog-sample.
@BonoboBoner: We understand it’s skeleton code for a larger project, requiring a bit larger initial code. But if this pattern requires this much code, spread across so many files, it must be a nightmare to maintain as a project grows.
The stack you’ve mention is not the best one inspired by the video. MVP4G (http://code.google.com/p/mvp4g/) is a better implementation of MVP/DI/Events ideas expressed during the talk.
@Stakka: “spread across so many files, it must be a nightmare to maintain as a project grows.”
Actually it is easier to maintain (at least that was my impression after porting my helloworld-style-spaghetti-code to a structured MVP-approach), since your widgets know nothing about data access for example. When trying to swap out a GWT-Tree with a TreePanel from GXT for example, you can leave the RPC as it is and just have to register a different event source for selection of tree-items, etc. It is far easier to unit-test as well.
I agree with Oleks. The example really needs to have sufficient complexity to support the idioms being expressed. Although this example (http://code.google.com/webtoolkit/doc/latest/tutorial/mvp-architecture.html) does not show all the elements (it is missing GIN, command pattern, and a few others), it does present a “simple as possible” example of how to use MVP and event bus along with introductory unit test setup. I would like to know if anyone has seen a solid implementation of the command pattern anywhere. I would like to use that pattern in my upcoming GWT app. thanks in advance.