I used GWT at 1.2.x for a while and did a little project on that. and then never use GWT too much. Recently, GWT 2.1 RC 1 is released. I think why not pick it up. This blog aims to summary some related infos and my tips on GWT2.1 RC 1 MVP (Modle-View-Presenter) subject.
As every other new framework or technology, GWT MVP framework has many terms and some of them are not so intuitive. However, Google alway offers documentations and examples.
Here is a list of google references on this subject:
Sample app helloMVP
How to use google-gin in the helloMVP example (on-going discussion on google group)
Thomas Broyer on his blog wrote a serie of article over the MVP concept
In this blog, I am going to try explain the concept very briefly and give a example.
Place:
one place is one bookmark-able URL of your GWT app, each place has its own String token, and each place can be accessed via a URL. For example, you application URL is localhost:8888, your place A's string token is "home", the URL for this place is localhost:8888#home.
Place is just a java class, you put state information into it.
Activity:
IMO really a bad naming, Activity is a presenter in MVP term. one place should point to a activity. It is possible to point multiple place to the same activity. As mentioned, place can contains state, so you choose activity to response different state.
View:
In GWT MVP, Activity supposes to fetch the view, and add the view to the page.
so Place-->Act-->View-->Other Places
to glue act and place together, we need PlaceHistoryMapper , ActivityMapper, and ActivtiyManager. PlaceHistroyMapper is mapping string token to place, ActivtiyMapper is mapping place to activity, and ActivityManager is charge off handle the PlaceChangeEvent and execute the activity.
Next blog will give a example using gwt mvp framework
No comments:
Post a Comment