"core" refers to the initial piece of the application that is loaded.
In order to bind url to places, GWT uses PlaceTokenizer<P extends Place>
. When loading the application from the url, it calls the method P getPlace(String token)
to retrieve a new instance of the place to call.
due to the asynchronous nature of code splitting, I can't create the place inside a runAsync
in this method. So I have to put all the places of my app in the core.
To link places to activity, GWT callsActivity getActivity(Place place)
(from com.google.gwt.activity.shared.ActivityMapper
) to retrieve a new instance of the activity.
Once again, i have to put all my activities in the core.
Here's what I want to try: Write a custom com.google.gwt.place.shared.Delegate
that
PlaceChangeRequestEvent
. If the AppPiece corresponding to the requestedPlace isn't loaded, it calls event.setWarning(NEED_TO_LOAD_MODULE)
confirm(String message)
method, always return false when the message equals NEED_TO_LOAD_MODULE
(so it doesn't bother the user), and load the module via RunAsync
.goTo(requestedPlace)
Each AppPiece of my application contains a bunch of activies and the corresponding views. Since the mappers are only called when PlaceChangeEvent
is fired, i could generate a new instance of my activity via AppPiece.getSomeActivityInstance()
.
I'm pretty sure this will work, but what bother me is that
Delegate
for this purpose is tricky, and I'm looking for a better solutionYou don't have to put all your activities in the core (as you call it): while an Activity instance is retrieved synchronously, it's allowed to start asynchronously. This is where you'd put your GWT.runAsync
call.
See http://code.google.com/p/google-web-toolkit/issues/detail?id=5129 and https://groups.google.com/d/topic/google-web-toolkit/8_P_d4aT-0E/discussion