Sorry, feel like I might be missing some info to you. I've basically
got two items:
3 Places
- ContactPlace
- EditContactPlace
- NewContactPlace
which map to 2 activities:
- ContactActivity
- EditContactActivity
the contact activity is initally loading fine, but there is a click to
add a new contact which is supposed to load the NewContactPlace.
I'm passing the provider to the ContactActivity as so:
@Inject
public ContactActivity(EventBus eventBus, IContactsViewDisplay
display,
PlaceController
placeController,
ContactsServiceAsync
rpcService,
Provider<NewContactPlace> newGoToPlaceProvider,
Provider<EditContactPlace> editGoToPlaceProvider) {
this.rpcService = rpcService;
this.eventBus = eventBus;
this.display = display;
this.placeController = placeController;
this.newGoToPlaceProvider = newGoToPlaceProvider;
this.editGoToPlaceProvider = editGoToPlaceProvider;
}
And forwarding to the newcontactplace here:
ContactActivity.this.placeController.goTo(newGoToPlaceProvider.get());
It's the above line (that although it kicks off and moves to the New
Contact Page, it's giving a null pointer exception and not updating
the URL.
My AppPlaceFactory is exactly as Amir mentioned above.
Would really appreciate some help on this.
Cheers
Moe
On Oct 23, 11: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.getPrefixAndToken(AppPlaceHistoryMapperImpl.java:
> 24)
> at
> com.google.gwt.place.impl.AbstractPlaceHistoryMapper.getToken(AbstractPlaceHistoryMapper.java:
> 66)
> at
> com.google.gwt.place.shared.PlaceHistoryHandler.tokenForPlace(PlaceHistoryHandler.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(Singleton.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.