Place, history url does not change

329 views
Skip to first unread message

Rikard Hultén

unread,
Oct 20, 2011, 1:41:29 PM10/20/11
to google-we...@googlegroups.com
I wan't the plain vanilla activites, places and history handling just as explained on GWT site.

The place and activity seems to work, the placeChangeEvent is fired and all but the URL does not change. This is when I have a Anchor-widget with a clickhandler that uses the presenter.goTo

if I instead use a HyperLink the URL change but then the activity does not change and nothing happens...

I cannot see my error. The history handling is not set up somehow, if I manually enter the expected #place:token it does not work either.

Below is my "setup" in onModuleLoad

GWT 2.4 btw

============================================

Place defaultPlace = new TaskListListPlace();
SimplePanel appWidget = new SimplePanel();

ClientFactory factory = GWT.create(ClientFactory.class);
EventBus eventBus = factory.getEventBus();
PlaceController placeController = factory.getPlaceController();

ActivityMapper activityMapper = new AppActivityMapper(factory);
ActivityManager activityManager = new ActivityManager(activityMapper, eventBus);
activityManager.setDisplay(appWidget);

AppPlaceHistoryMapper historyMapper = GWT.create(AppPlaceHistoryMapper.class);
PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper);
historyHandler.register(placeController, eventBus, defaultPlace);

RootPanel.get("app").add(appWidget);
historyHandler.handleCurrentHistory();

eventBus.addHandler(PlaceChangeEvent.TYPE, new PlaceChangeEvent.Handler() {
@Override
public void onPlaceChange(PlaceChangeEvent event) {
  Window.alert("Place change event!");
}
});

Thomas Broyer

unread,
Oct 20, 2011, 1:52:29 PM10/20/11
to google-we...@googlegroups.com
If you set breakpoints in your PlaceTokenizers and in DefaultHistorian, are they correctly hit?

Rikard Hultén

unread,
Oct 20, 2011, 2:40:12 PM10/20/11
to google-we...@googlegroups.com
The Tokenizers never get hit no, which is interesting but I don't know how where to continue searching...

Not sure what you mean by DefaultHistorian?

In the AppPlaceHistoryMapper interface I just enumerate my tokenizers from the places in the @WithTokenizers, just like in the activites-places-article.

From what I can read it is the PlaceController that is responsible for updating the URL, and as the event gets fired on the same event bus as is passed in to it I can't understand why it does, in fact, not update the URL.

I run this in the out-of-the-box GPE development server and Chrome with the GWT plugin.

Ashton Thomas

unread,
Oct 20, 2011, 5:01:08 PM10/20/11
to google-we...@googlegroups.com
You have "presenter.goTo(new MyPlace());" but why isn't it placeController.goTo(new MyPlace());?? Sorry not sure how your app is set up but I know I just inject the PlaceController and call it directly and then that eventually hits ActivityManager that calls the next Activity while the url is updated as well.

Rikard Hultén

unread,
Oct 21, 2011, 12:44:20 AM10/21/11
to google-we...@googlegroups.com
I have tried to set things up like in the article on the GWT page.

The presenter does looks up the placecontroller and invokes its goTo, this changes the place and the new activity is started, but the URL stays the same :(

Rohan Aggarwal

unread,
Oct 21, 2011, 12:51:15 AM10/21/11
to google-we...@googlegroups.com
I have faced similar problem, I think below are few from code snippet:

1. Placecontroller should be singleton across ur app.

2. You should bind activity and Place ...

3. I am not seeing any activities in ur sample.



On Fri, Oct 21, 2011 at 10:14 AM, Rikard Hultén <rikard...@gmail.com> wrote:
I have tried to set things up like in the article on the GWT page.

The presenter does looks up the placecontroller and invokes its goTo, this changes the place and the new activity is started, but the URL stays the same :(

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/GlgbmjhTUkEJ.

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.

Rikard Hultén

unread,
Oct 21, 2011, 2:09:19 AM10/21/11
to google-we...@googlegroups.com
1. The PlaceController is created once in the client factory, so it should be singleton

2. Not sure what you mean by "bind"? I look up activity from place in the ActivityMapper just as in the example

3. Rest assured I do have two activities, implementing the presenter interface from each view interface. I don't have the code on this computer so I can't post any code, but it is very simple activities where one has a link (Anchor widget) that kicks of the other. It just occurred to me I should debug the activity to see what place is passed in, since the place tokenizers aren't called.

Thomas Broyer

unread,
Oct 21, 2011, 5:33:40 AM10/21/11
to google-we...@googlegroups.com


On Thursday, October 20, 2011 8:40:12 PM UTC+2, Rikard Hultén wrote:
The Tokenizers never get hit no, which is interesting but I don't know how where to continue searching...

Not sure what you mean by DefaultHistorian?


In the AppPlaceHistoryMapper interface I just enumerate my tokenizers from the places in the @WithTokenizers, just like in the activites-places-article.

From what I can read it is the PlaceController that is responsible for updating the URL, and as the event gets fired on the same event bus as is passed in to it I can't understand why it does, in fact, not update the URL.

No.
The PlaceController fires events on the bus, and the PlaceHistoryHandler listens to them to call its Historian (after converting the place to a token using the PlaceHistoryMapper), which is responsible for updating the URL. The Historian will also listen to the URL changing (such as using the "back" button of your browser) and PlaceHistoryHandler will map the token to a place (still using the PlaceHistoryMapper) and call goTo on the PlaceController.

HTH

Rikard Hultén

unread,
Oct 21, 2011, 6:11:08 PM10/21/11
to google-we...@googlegroups.com
Thank you very much Thomas, when breaking on tokenForPlace in PlaceHistoryHandler I saw that it did not find a place for my token, although it was the correct token-string. Turned out I had declared the same tokenizer twice in my AppPlaceHistoryMapper (the places are called TaskListPlace and TaskListListPlace hehe).

I also did not expect the default place to get an empty history token, threw me off a bit.

Anyway, got it working by fixing the AppPlaceHistoryMapper. 

Thanks everybody!
Reply all
Reply to author
Forward
0 new messages