Hi

In my application, I'm using the MVP pattern with activities and
places.  I have a situation where:

(1) I explicitely call: placeController.goto(new SomePlace());
(2) The appropriate SomePlaceActivity's start() gets called via event
management as expected.
(3) This method creates gets a SomePlaceView, and swaps it into the UI
(4) An appropriate history event happens and 
http://mylocalenvironment#SomePlace:someplace
appears briefly on my browser's nav bar.

Then it gets weird.

(5) A new empty String token gets created somehow.
(6) It goes through the history management process, causing the
defaultPlace to be created
(7) The start() method on DefaultPlaceActivity() gets called
(8) The app navigates away from SomePlace to DefaultPlace

which makes me sad and very confused.  I cannot figure out how that
empty token gets created and the event handling mechanism gets invoked
the second time. The code for this is, of course, spread over many
files so its difficult to provide all the relevant code, but I've
included much of what I think could be useful here. I'm hoping that
people have seen this happen before and can point me to a typical
cause.

// from my ActivityMapper
        public Activity getActivity(Place place) {
            if (place instanceof LoginPlace)
                return new LoginPresenter((LoginPlace) place,
factory);
            else if (place instanceof SomePlace )
                return new SomePlaceActivity((SomePlace) place,
factory);
            else if (place instanceof ForgotPasswordPlace )
                return new
ForgotPasswordPresenter((ForgotPasswordPlace) place, factory);

            return null;
        }

// from SomePlace

public class SomePlace extends Place {
    private final String name = "somePlace";

    public SomePlace() { }

    public String getName() { return name;}

    public static class Tokenizer implements PlaceTokenizer<SomePlace>
    {

        public String getToken(SomePlace place)
        {
            return place.getName();
        }

        public SomePlace getPlace(String token)
        {
            return new SomePlace();
        }
    }
}

// from SomePlaceActivity

public class SomePlaceActivity extends AbstractActivity implements
Activity {

    private ClientFactory clientFactory;
    private SomePlace place;

    public SomePlaceActivity(SomePlace place, ClientFactory
clientFactory){
        this.clientFactory=clientFactory;
        this.place = place;
    }

    public void start(AcceptsOneWidget panel, EventBus eventBus) {
 
clientFactory.getMainPanel().replaceCenter(clientFactory.getSomePlaceView().asWidget());
    }
}

// from my entrypoint class's onModuleLoad() method

                ActivityMapper activityMapper = new
ClientFactoryImpl.Controller(clientFactory);
                ActivityManager activityManager = new
ActivityManager(activityMapper, clientFactory.getEventBus());

        
activityManager.setDisplay(clientFactory.getMainPanel().getCenter());

                AppPlaceHistoryMapper historyMapper=
GWT.create(AppPlaceHistoryMapper.class);
                PlaceHistoryHandler historyHandler = new
PlaceHistoryHandler(historyMapper);
                historyHandler.register(placeController,
clientFactory.getEventBus(), defaultPlace);

                // Goes to place represented on URL or default place
                historyHandler.handleCurrentHistory();


// from my AppPlaceHistoryMapper interface


@WithTokenizers(
        {
                LoginPlace.Tokenizer.class,
                SomePlace.Tokenizer.class,
                ForgotPasswordPlace.Tokenizer.class
        })

    public interface AppPlaceHistoryMapper extends PlaceHistoryMapper
{

}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to