FilteredActivity

46 views
Skip to first unread message

Thomas Lefort

unread,
May 9, 2012, 10:12:32 AM5/9/12
to google-we...@googlegroups.com
Hi,

I have the following issue: I use a FilteredActivityMapper with the following filtering:

@Override
public Place filter(Place place) {
if(// check user is logged in) {
return new EIRegisterPlace("", place);
                }
        return place;
}

Filtering works well except that when the user logs in I call placeController.goTo(nextPlace) and the code gets stuck. The reason is that the "where" variable is still set to the old place (and not the EIRegsiterPlace), so where = nextPlace and the placeController gets blocked.

Any idea if this normal (that the place doesn't change to "EIRegisterPlace")? and is there a workaround? another way of proceeding?

Thanks,

Thomas

Jens

unread,
May 9, 2012, 10:45:10 AM5/9/12
to google-we...@googlegroups.com
Any idea if this normal (that the place doesn't change to "EIRegisterPlace")?

Yes thats normal. A FilteredActivity allows you to change activities for a given place by temporary converting the current place to a different one to trick the underlying ActivityMapper. So its not meant to globally transform one place into another. Thats why PlaceController always contains the place you call goTo() with.
 
and is there a workaround? another way of proceeding?

You could copy the PlaceController.goTo() method and omitting the oldPlace.equals(newPlace) check. So you basically fire PlaceChangeRequestEvent and PlaceChangeEvent yourself and not through PlaceController.goTo(). That way you can "reload" the current place.

-- J.

Thomas Lefort

unread,
May 9, 2012, 11:41:47 AM5/9/12
to google-we...@googlegroups.com
Brilliant, that does work indeed! Thanks.

Jens

unread,
May 9, 2012, 12:22:12 PM5/9/12
to google-we...@googlegroups.com
No problem, but keep in mind that you now have two browser history entries which are both the same. So you should not use this throughout your app if you need to reload things otherwise the browsers back/forward buttons would feel odd. For login its probably ok.
Reply all
Reply to author
Forward
0 new messages