Calling placecontroller.goto from within the activity mapper

130 views
Skip to first unread message

P.G.Taboada

unread,
Jul 12, 2011, 9:20:36 AM7/12/11
to Google Web Toolkit
Hi,

I have to do a "place redirect" in my app. Actually I am calling goto
inside of my activity mapper, it is working. I just wanted to get
feedback to see if I am doing it right.

When I have to do a "place redirect", I am

- returning null in the activity mapper
- "finally" scheduling a goto to the new place

By finally scheduling the new goto I was hoping to escape the original
activity/ place lifecycle (which is returning null) and starting a new
one.

Not shure if I should trigger a finally scheduled command or a
deferred one. The latter does not feel right, but I am not sure.

Any comments welcome.

P.G.Taboada

unread,
Jul 12, 2011, 10:21:31 AM7/12/11
to Google Web Toolkit
Just in case someone is wondering why I did not use a
FilteredActivityMapper: the activity manager would work perfectly, the
problem is the ActivityController: it does not see the "place
redirect". This way the place controller does not really know where
the application is.

Here is my problem: I have a "haveToGoHereFirst" place.

placecontroller.goto(somewhere);

==> now placecontroller thinks we are somewhere

filter changes to haveToGoHereFirst(whereDidIComeFrom)

activity mapper returns activity for haveToGoHereFirst

haveToGoHereFirst does some work, and finally takes the user where it
wanted to go to in first place by calling placecontroller
goto( somewhere )


==> now nothing happens. the place controller sees you going to
somewhere again and does not trigger the place request.


To fix this, we shold add the place filter to the placecontroller, and
have a activity filter on the activity mapper. the way it is, it is
imho broken.

Thomas Broyer

unread,
Jul 12, 2011, 10:41:49 AM7/12/11
to google-we...@googlegroups.com
I can see several ways of "fixing" this (depending on the exact use case you're trying to solve):
  • assuming this is "on initial load": have your "have to go to here first" logic in the PlaceTokenizer, to return the HaveToGoHereFirstPlace
  • add a flag to your "somewhere" places that, when set, changes the equals() implementation to always return false; that way, "somewhere"(initial) is different from "somewhere"(from haveToGoHereFirst). Actually, depending on your needs, you might not even need the flag, and simply not override equals(), having each instance only equals() itself (default behavior from Object#equals)
  • don't redirect automatically, instead, return an activity that displays a "you should go there first" message to the user.
  • implement the whole thing within the activity/activities itself, possibly wrapping it within a special HaveToReadThisFirstActivity to keep concerns separate, and using another mean than a goTo(Place) to switch from the "haveToGoHereFirst" screen to the "actual" activity.
There might be other solutions.
Reply all
Reply to author
Forward
0 new messages