`
flashcloud
  • 浏览: 185741 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

MVP For GWT 系列资料转载十:Loading a default view on startup with gwt-presenter

    博客分类:
  • GWT
GWT 
阅读更多

源文转自:Loading a default view on startup with gwt-presenter

 

As shown in Chris Lowe’s GWT MVP example, I’ve been using getPlaceManager().fireCurrentPlace() in my EntryPoint class to show the initial view after all presenters are loaded. This works fine if there is a history token (placeId) in the URL; however, on initial load, my URL is empty, so I want to navigate to the default view and mark the Place in History (I chuckle every time I use that phrase). The simplest way to do this is to fire a PlaceRequestEvent, so my GWT EntryPoint class now concludes with this:

 

// Load PlaceManager so it can start listening
PlaceManager placeManager = injector.getPlaceManager();

String currentPlace = History.getToken();
if ("".equals(currentPlace))
{
	// Nothing in URL, load default page
	injector.getEventBus().fireEvent(
			new PlaceRequestEvent(new PlaceRequest(
					ManageListsPresenter.PLACE)));
}
else
{
	// Load requested page
	placeManager.fireCurrentPlace();
}

 

My default presenter is contained within a WidgetContainerPresenter, and gwt-presenter calls the appropriate methods to reveal my default view, set it as the current presenter in the container, and update the URL in the address bar. Slick.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics