Friday, April 29, 2011

Grouping multiple presenters

Mvp4g is a great library to manage your large GWT application structure. Especially when using MVP where your Presenters talk to each other using events. Without Mvp4g you can follow plain vanilla GWT but you will need to create and manage a set of Handlers and Events to communicate those presenters. And on top of that, you’ll need to manage the registry and instantiation of those presenter instances.

In an application we recently built we used Mvp4g. We had this special requirement that the screen layout was to be built dynamically. That meant we would need to create presenters on the fly, but not only that, there might be multiple instances of a presenter at any given time - e.g. one screen would have two chart components with different supporting data. The presenter responsibility was the same for both, display a bar chart from the under laying data (a simple multi-column query).

I’ve used a simple concept of sender and receiver for events in groups. These are really simple implementations of one presenter sending events on list box value change and another presenter receiving that event. Look at the sample demo:

Quick running demo with this idea implemented


This blog series is divided in three parts (follow the links for the implementation details):


3 comments:

  1. Thanks for the tutorial. Just getting started with mvp4g and this helps!

    ReplyDelete
  2. An example of adding a presenter on the fly would be nice

    ReplyDelete
  3. Thanks for sharing with us, I will be always your follower.
    Event Presenter

    ReplyDelete