Architecting your Google Web Toolkit GWT apps with Model View Presenter ( MVP) At its core, MVP is a design pattern that breaks your app up into the. Main Components of GWT MVP. Framework. • Model. – Responsible for holding raw data. – No business logic allowed (just like any model really). • Example. Modular design for large-scale apps, similar to the widely-accepted MVC approach in “normal” Web applications.

Author: Durg Shaktigrel
Country: Peru
Language: English (Spanish)
Genre: Career
Published (Last): 26 September 2006
Pages: 488
PDF File Size: 7.34 Mb
ePub File Size: 18.12 Mb
ISBN: 505-6-25111-809-2
Downloads: 56233
Price: Free* [*Free Regsitration Required]
Uploader: Tojazilkree

Stack Overflow works best with JavaScript enabled. The sample project, referenced throughout this tutorial, can be found at Tutorial-Contacts. All we are doing here is changing the history token to have a value defined in the Tokens class to represent Photo Detail view appended by the photo id the user is interested in. The reason being is that the app is really only concerned when some state has changed contact values changed, contact deleted, etc…which is the case after the RPC has returned.

Binding presenters and views Events and the event bus History and view transitions Testing Sample Project The sample project, referenced throughout this tutorial, can be found at Tutorial-Contacts. Care to explain downwote? In the application controller, we will create presenters in the following manner:. A representation of a contact within the contact list.

GWT MVP Development with Activities and Places |

Each example is set up to test adding a list of ContactDetails, sorting those ContactDetails, and then verifying that the sorted list is correct. Just before we jump to the AppController, which is responsible for tying everything together and starting presenters, we want to take a little deeper look at the relationship between presenter and views we have used. In the case of our example application, this optimization has less impact than it would in a more complex app where Contact objects have substantially more fields.


Multiple components can be listening for a single event, so when an event is fired using the EventBus. However, you will see that we specifically make the presenter register itself in the view, and that the view notifies the presenter by calling appropriate registered presenter methods when events are raised. In order for the app to do something meaningful, the presenter is going to need to:. Method setData is a simple way of getting model data into the view without the view having intrinsic knowledge of the model itself.

App-wide events are really the only events that you want to be passing around on the Event Bus. While the list of photos is being retrieved, a busy message is displayed to the user.

Building GWT Applications with MVP and Issues with Overlay Types

This action shows the user the new photo details view with the requested image, while the AppController sits there waiting for the next history change. It may not be easy to grasp from a programmatical point view at the begining, but the theory is pretty clear.

Nice words, but what does it mean? In the specific presenter interface we wish to declare those methods that will be called from the view when things happen.

The view is completely passive and every interaction of the view with the model is done through the Presenter. For example, we grab resources such as the RPC service and the event bus – we might as well share the RPC service for efficiency, and we have to share the event bus; otherwise, it would not be system wide.

Multiple developers working simultaneously on the same code base, while maintaining legacy features and functionality, can quickly turn into messy code. Since the view transition logic is already built into the onValueChange method, this provides a centralized, reusable way of navigating within the app. Not a tutorial but I wrote one sample that one can use as a skeleton.

Fortunately, there is a well known solution to this problem: For our sample we have the following Presenters: Tutoiral number and granularity of models is a design decision.


Presenter A presenter contains all of the logic for our Contacts application, including history managementview transition and data sync via RPCs back to the server. At the heart of mvl pattern is the separation of functionality into components that logically make sense, but in the case of GWT there is mvl clear focus on making the view as simple as possible in order to minimize our reliance on GWTTestCase and reduce the overall time spent running tests.

He also pointed me to his tdd-gwt-gae project which shows many techniques for unit testing with jMock and integration testing with GWTTestCase. Building any large scale application has its hurdles, and GWT apps are no exception. In our PhotoApp, we will have one very simple model:.

Again, in order to reap the benefits of the MVP model, the presenter should have no knowledge of any widget-based code. Take for example the ContactsView:. Usually, unit tests tutoriwl only applied to business logic and the model.

The other is that all our views will extends the IsWidget interface. More specifically, we have to make sure our presenters are solely relying on plain old Java code. Your links aren’t about that.

GWT MVP Development with Activities and Places

This is not a requirement to have, but suits us well as it creates a basic contract that all our views will adhere to, and that other components are aware of and can trust. Thus if user specifies http: Our application has two views: Click here to view the complete list tutorail archived articles. The general flow, as shown in the following code, is:.