TurboManage

David Chandler's Journal of Java Web and Mobile Development

  • David M. Chandler


    Web app developer since 1994 and Google Cloud Platform Instructor now residing in Colorado. Besides tech, I enjoy landscape photography and share my work at ColoradoPhoto.gallery.

  • Subscribe

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 228 other followers

  • Sleepless Nights…

    October 2009
    S M T W T F S
     123
    45678910
    11121314151617
    18192021222324
    25262728293031
  • Blog Stats

    • 1,010,175 hits

Archive for October 9th, 2009

Correction to previous post

Posted by David Chandler on October 9, 2009

I made a serious mistake in my previous post and spent all evening looking for it 😦

A side effect of the if block in the previous post is that the PlaceManager doesn’t get loaded if the URL is empty. I’ve now corrected it to always load the PlaceManager, as gwt-presenter doesn’t work at all without it.

Posted in Google Web Toolkit, Model-View-Presenter | Leave a Comment »

Loading a default view on startup with gwt-presenter

Posted by David Chandler on October 9, 2009

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.

Posted in Google Web Toolkit, Model-View-Presenter | Leave a Comment »

 
%d bloggers like this: