Question

Behold, my first GWT app's EntryPoint impl:

public class MyModule implements EntryPoint {
    private SimplePanel mainPanel = new SimplePanel();

    @Override
    public void onModuleLoad() {
        // Extract all root-level dependencies from the injector.
        // Using Gin here.
        EventBus eventBus = injector.getEventBus();
        PlaceController placeController = injector.getPlaceController();
        SignInEventListener signInEventListener = injector.getSignInEventListener();
        PlaceHistoryMapper placeHistoryMapper = injector.getPlaceHistoryMapper();

        // Start the activity manager.
        activityManager = new ActivityManager(signInEventListener, eventBus);
        activityManager.setDisplay(mainPanel);

        // Start the place history mapper.
        placeHistoryHandler = new PlaceHistoryHandler(placeHistoryMapper);
        placeHistoryHandler.register(placeController, eventBus, startingPlace);

        // Add the main panel to the RootPanel.
        RootPanel.get().add(mainPanel);

        // Navigate to the place represented by the current URL, otherwise the startingPlace.
        placeHistoryHandler.handleCurrentHistory();
    }
}

Several questions:

  1. My call to the placeHistoryHandler's register(...) method is showing up as being deprecated. Why is it deprecated and what should it be (as of GWT 2.5.1)?
  2. Is there one RootPanel per module/EntryPoint or is there only one RootPanel per GWT app (regardless of how many modules you have)?
  3. What is the connection/relation between the mainPanel (above) that itself has been added to the RootPanel, and the AcceptsOneWidget that gets passed into each AbstractActivity#start method?
Was it helpful?

Solution

  1. Look here: GWT deprecated: PlaceHistoryHandler.register?
  2. The RootPanel is most likely the <body> element. So there is exactly one.
  3. In most cases you will add one AcceptsOneWidget to the RootPanel. Your Activity has to create its view and set it into the AcceptsOneWidget passed to the start()

Take a look at the Activity and Places section of gwtproject.org

OTHER TIPS

1) See Christian Kuetbach answer

2) In your GWT app you should have a MyModule.html file. This file has been define as the welcome file in your web.xml file. Inside this file you will see that is included the javascript version of your application MyModule.nocache.js (after gwt compilation). The RootPanel as said by Christian is the of your html page. Be careful you can use RootLayoutPanel or RootPanel depending if you want to use Layout Panels or not.

3) When using Activities and Places, the Activity Manager is given a widget container. Inside this widget container the framework will put the view of the new activity when changing place. That is the meaning of

activityManager.setDisplay(mainPanel);

Your are saying that when you go from one place to another, the activity view that corresponds to that place should be put inside mainPanel.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top