My understanding of GWT's Activities and Places is that for a given region on a screen you have an ActivityManager
and an ActivityMapper
. You can have multiple regions on the screen which means you can have multiple ActivityManagers
and ActivityMappers
(one per region). So, whenever there is a PlaceChange
the ActivityManagers
ask their respective ActivityMapper
what activity it is supposed to be showing given the Place
. This works great as long as your Places
all have a common layout that they reuse in different ways to perform different activities. My question is how do we handle the case where different Places
use radically different layouts? My first thought is to just have even more ActivityManagers
and ActivityMappers
, if the Place
doesn't use a particular region then the ActivityMapper
for that region will simply return null
when we change to that Place
. If there is a better way I would appreciate any wisdom.
-
3I don't think there's a _better_ way. See http://tbroyer.posterous.com/gwt-21-activities-nesting-yagni – Thomas Broyer Oct 22 '12 at 15:26
-
Thank you, that article was perfect. – tleef Oct 22 '12 at 15:34
1 Answers
I found it much easier to use a single ActivityMapper/ActivityManager pair for the entire app.
In a typical case you have a "menu" region and a "main" region. The menu region is very basic: a click on a menu item sends a user to a new place. It also highlights the newly selected item and resets the style of the previously selected item. All of this can be easily done in a simple widget that you can include in all views where this menu is required. Having separate ActivityMapper and ActivityManager for the menu region just complicates everything without providing any benefits.
I use the same approach for "top menu" region and "left menu/tree" region: a widget that tells the presenter which data to show in the "main" region.
I have over 50 different places in my app, and it really helps to have a simple architecture: each place corresponds to one view and one activity.

- 40,755
- 6
- 49
- 58
-
Do you make a point of avoiding multiple Activities for a single Place so that you can use that structure or do you have some way of still supporting multiple Activities while using a single ActivityManager/ActivityMapper? – tleef Oct 22 '12 at 16:01
-
I avoid using multiple activities. I never encountered a UI design where two regions are simultaneously involved in a kind of complex and independent behavior that warrants a dedicated activity per region. I guess such designs are possible, but I believe that creating a dedicated activity for a menu or a tree creates more problems that it solves. – Andrei Volgin Oct 22 '12 at 17:45