2

I'm managing the History in my project via Places.

What I do is this:

  • implement PlaceRequestHandler on top level (for example AppController),
  • register it -> eventBus.addHandler(PlaceRequestEvent.getType(), this);
  • implement method "onPlaceRequest" ,where i do project navigation.

I'm using GWT presenter and every presenter in my project overrides the onPlaceRequest method.

Why do I need this, when every request is handled from the top level "onPlaceRequest" method?

I will give an example:

public class AppController implements Presenter, PlaceRequestHandler
...........
public void bind()
{
  eventBus.addHandler(PlaceRequestEvent.getType(), this);
...
}
public void onPlaceRequest(PlaceRequestEvent event)
{
// here is the project navigation tree
} 

and let's take one presenter

public class SomePresenter extends Presenter<SomePresenter.Display>
{
... here some methods are overriden and 

@Override
protected void onPlaceRequest(PlaceRequest request)
{
// what should I do here? 
}
}

What is the idea, and how I'm supposed to use it?

kapandron
  • 3,546
  • 2
  • 25
  • 38
adgfs
  • 423
  • 6
  • 17
  • Too bad that you deleted http://stackoverflow.com/questions/7229931/jsf-problem-when-dispalying-userbean-properties while I was typing a world class answer. At least, it boils down to that you was reading world's worst Java EE tutorial. Put roseindia.net in your Internet blacklist! – BalusC Aug 29 '11 at 13:00
  • hi BalusC, sorry about that. I did't know that and i thought that the question is not interesting to anyone. You are right about roseindia.net... – adgfs Sep 01 '11 at 12:38
  • Not interesting to anyone? Did you expect answers within minutes? C'mon. – BalusC Sep 01 '11 at 12:40

1 Answers1

2

Instead of making all of your presenters extend PlaceRequestHandler and managing those events yourself, you can attach a PlaceHistoryHandler and a PlaceController to your event bus. Together, they manage the browser's history and your places for you. When you ask your PlaceController to goTo() a different place, it will stop your current activity and use a mapping of places to activities (your presenters) to choose which one to start next.

To use this technique, you need to have your presenters extend AbstractActivity. Try following through Google's tutorial about it in GWT's documentation called GWT Development with Activities and Places.

ben_w
  • 736
  • 1
  • 6
  • 10