Nested Activities

308 views
Skip to first unread message

Daniel Simons

unread,
Dec 13, 2010, 11:57:03 AM12/13/10
to Google Web Toolkit
I have solution for nesting activities that appears to work for all general cases.  I would like to share my solution and find out how others are solving this problem.  Here is my process:

1) for each panel of my site I have a unique Activity Manager/Mapper
2) the mapper maps to one or more activities via the 'getActivity' method
3) when a place change occurs getActivity is called for each mapper and has 3 possible outcomes 
      a) returns a new Activity so that it can update its associated panel
      b) returns the current Activity so that the panel does not change (stays the same as from previous state)
      c) returns null so that the panel is removed from the ui

Note the above solution requires keeping a copy of the current Activity inside each Activity Mapper.  Does anyone see flaws in this solution?  If so could you provide a more appropriate way to solve this?

Thanks,
Daniel

Myles Bostwick

unread,
Dec 13, 2010, 12:17:30 PM12/13/10
to google-we...@googlegroups.com
I'm solving this problem slightly differently. My exact problem is that I have "plugins" into my main application that based on configuration will be compiled in or not. So at the top level I have no idea what activities will be present or not until compile time.

What I did was create a generator that generates my ActivityMapper at compile time based on the Activity classes found. I then use annotations to link activities to places or default to convention, ie. FooActivity maps to FooPlace. Then, as you've done, my ActivityMapper has a getActivity that returns a new instance of the activity.

David Chandler

unread,
Dec 13, 2010, 12:24:53 PM12/13/10
to google-we...@googlegroups.com
Hi Daniel,

This sounds a lot like what I described in
http://groups.google.com/group/google-web-toolkit/msg/2debad456eda5de9
and it seems to be the pattern that's emerging.

There's some great stuff from the community on that thread re: code
splitting and GIN, too.

/dmc

> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to google-we...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-tool...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>

--
David Chandler
Developer Programs Engineer, Google Web Toolkit
http://googlewebtoolkit.blogspot.com/

Thomas Broyer

unread,
Dec 13, 2010, 1:53:57 PM12/13/10
to google-we...@googlegroups.com


On Monday, December 13, 2010 5:57:03 PM UTC+1, Daniel wrote:
I have solution for nesting activities that appears to work for all general cases.  I would like to share my solution and find out how others are solving this problem.  Here is my process:

1) for each panel of my site I have a unique Activity Manager/Mapper
2) the mapper maps to one or more activities via the 'getActivity' method
3) when a place change occurs getActivity is called for each mapper and has 3 possible outcomes 
      a) returns a new Activity so that it can update its associated panel
      b) returns the current Activity so that the panel does not change (stays the same as from previous state)
      c) returns null so that the panel is removed from the ui

I don't see nesting here.
It's exactly how activities are meant to be used (from what I've been told): http://tbroyer.posterous.com/gwt-21-activities-nesting-yagni
 
Note the above solution requires keeping a copy of the current Activity inside each Activity Mapper.  Does anyone see flaws in this solution?

No, that's how it's supposed to work. You can use a CachingActivityMapper though instead of doing the book keeping yourself (possible coupled with a FilteredActivityMapper so the Place that reaches the CachingActivityMapper can be compared equal to the previous place).
Have a look at the Expenses sample, that's exactly what it does for the "master" activities.
 

Thanks,
Daniel

Ronan Quillevere

unread,
Jan 17, 2014, 7:23:43 AM1/17/14
to google-we...@googlegroups.com
I tried to implement Thomas Idea on Not Nesting Activities if you are intered: 

Reply all
Reply to author
Forward
0 new messages