By the way, something I realised that although we can't map a 1-Many relationship between a Place and an Activity, you can in fact map multiple places to the same activity and differentiate between the place with multiple init() methods in the activity.
On Oct 24, 1:56 pm, moejo <[email protected]> wrote: > Hi Amir, > > Yes, your absolutely right - forgot to call setFactory! Now > everything is working stunningly. I've put together a sample bit of > code using the Contact Details code I mentioned previously and it can > be downloaded at: > > http://www.bright-creations.com/wp-content/uploads/2010/10/ContactsCl... > > If you guys have any comments about the code, please let me know. > Thanks for all your advice, you guys have been seriously helpful. > > Cheers > > Moe > > On Oct 24, 10:16 am, Amir Kashani <[email protected]> wrote: > > > Moe, > > > Are you using PlaceHistoryMapperWithFactory? If so, my best guess is > > that you're forgetting to call setFactory in your onModuleLoad(): > > > AppPlaceHistoryMapper historyMapper = > > GWT.create(AppPlaceHistoryMapper.class); > > historyMapper.setFactory(ginjector.getAppPlaceFactory()); > > > If that's not it, take a look at the generated code to see if you can > > figure out what exactly is null on that line (-gen compiler option). > > > HTH. > > > - Amir > > > On Oct 23, 2:54 pm, moejo <[email protected]> wrote: > > > > Hi All, > > > > I'm working on getting an example together and I am having issues > > > setting up the injectors for the code you've suggested above (Amir, > > > david, Aodhagán). So far, I've setup everything as you've suggested > > > for the AppActivityMapper, AppPlaceFactory, AppPlaceHistoryMapper, > > > Places and ActivityPlace. However, I am obviously missing something > > > in the GIN module itself (apologize in advance, just started to use > > > GIN). > > > > The pages are changing successfully, but no history token changes are > > > made. > > > > The error i get is: > > > > Caused by: com.google.gwt.event.shared.UmbrellaException: One or more > > > exceptions caught, see full set in UmbrellaException#getCauses > > > at > > > com.google.gwt.event.shared.SimpleEventBus.doFire(SimpleEventBus.java: > > > 214) > > > > Caused by: java.lang.NullPointerException: null > > > at > > > com.google.gwt.sample.contacts.client.mvp.AppPlaceHistoryMapperImpl.getPref > > > ixAndToken(AppPlaceHistoryMapperImpl.java: > > > 24) > > > at > > > com.google.gwt.place.impl.AbstractPlaceHistoryMapper.getToken(AbstractPlace > > > HistoryMapper.java: > > > 66) > > > at > > > com.google.gwt.place.shared.PlaceHistoryHandler.tokenForPlace(PlaceHistoryH > > > andler.java: > > > 156) > > > at com.google.gwt.place.shared.PlaceHistoryHandler.access > > > $1(PlaceHistoryHandler.java:151) > > > at com.google.gwt.place.shared.PlaceHistoryHandler > > > $1.onPlaceChange(PlaceHistoryHandler.java:103) > > > at > > > com.google.gwt.place.shared.PlaceChangeEvent.dispatch(PlaceChangeEvent.java > > > : > > > 57) > > > at > > > com.google.gwt.place.shared.PlaceChangeEvent.dispatch(PlaceChangeEvent.java > > > : > > > 1) > > > at > > > com.google.gwt.event.shared.SimpleEventBus.doFire(SimpleEventBus.java: > > > 204) > > > at > > > com.google.gwt.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java: > > > 103) > > > at > > > com.google.gwt.place.shared.PlaceController.goTo(PlaceController.java: > > > 120) > > > at com.google.gwt.sample.contacts.client.activity.ContactActivity > > > $1.onClick(ContactActivity.java:94) > > > > My NewContactPlace is as follows: > > > > public class NewContactPlace extends > > > ActivityPlace<EditContactActivity> { > > > > @Inject > > > public NewContactPlace(EditContactActivity activity) { > > > super(activity); > > > GWT.log("NewContactPlace.ActivityProvider: " + activity); > > > } > > > > private String placeName; > > > > public void setPlaceName(String token) { > > > this.placeName = token; > > > } > > > > public String getPlaceName() { > > > return placeName; > > > } > > > > @Prefix("new") > > > public static class Tokenizer implements > > > PlaceTokenizer<NewContactPlace> { > > > > // Since the place is injectable, we'll let Gin do the > > > construction. > > > private final Provider<NewContactPlace> placeProvider; > > > > @Inject > > > public Tokenizer(Provider<NewContactPlace> placeProvider) { > > > this.placeProvider = placeProvider; > > > GWT.log("NewContactPlace.Tokenizer.PlaceProvider: " + > > > placeProvider); > > > } > > > > @Override > > > public String getToken(NewContactPlace place) { > > > return place.getPlaceName(); > > > } > > > > @Override > > > public NewContactPlace getPlace(String token) { > > > NewContactPlace place = placeProvider.get(); > > > place.setPlaceName(token); > > > return place; > > > // If place requires any more work, do it here. > > > } > > > > } > > > > } > > > > However, (and I'm pretty sure here's the problem, is my GINModule: > > > > @Override > > > protected void configure() { > > > > // bind the EventBus > > > > > > bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class); > > > > bind(PlaceController.class).to(InjectablePlaceController.class).in(Singleto > > > n.class); > > > > // bind the mapper > > > > bind(ActivityMapper.class).to(AppActivityMapper.class).in(Singleton.class); > > > > // bind the views > > > bind(IContactsViewDisplay.class).to(ContactsView.class); > > > bind(IEditDisplay.class).to(EditContactView.class); > > > > } > > > > I've not used providers before, so I'm guessing I need to define a > > > provider? or is there somewhere else I might be missing. > > > > Any help would be much appreciated. > > > > Cheers > > > > Moe > > > > On Oct 22, 11:58 pm, Thomas Broyer <[email protected]> wrote: > > > > > On 22 oct, 19:50, David Chandler <[email protected]> wrote: > > > > > > Hi Richard, > > > > > > We're still working on an official story for how best to use runAsync > > > > > with Activities and Places. In the mean time, feedback on your > > > > > experiences is welcome. GWT's AsyncProxy class or the AsyncProvider in > > > > > GIN trunk look promising as ways to wrap Activity creation with a > > > > > runAsync() call. > > > > > > If view creation is initiated only through the corresponding Activity, > > > > > then wrapping Activity creation with runAsync() will defer loading of > > > > > the view code also, and you'll be able to see this in the SOYC report. > > > > > > References: > > > > >http://code.google.com/webtoolkit/doc/latest/DevGuideCodeSplitting.html > > > > >http://code.google.com/webtoolkit/doc/latest/DevGuideCompileReport.html > > > > > Just so it doesn't get forgotten, see > > > > alsohttp://code.google.com/p/google-web-toolkit/issues/detail?id=5129 > > > > I implemented the proposed ActivityAsyncProxy (see comment #4, as a > > > > concrete class, passing a GIN Provider<Activity> to the constructor) > > > > as a proof-of-concept but haven't used it yet (to tell the truth, not > > > > even tested it), so I cannot comment on how well/bad it works. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
