My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
FAQ  

Featured
Updated Aug 16, 2010 by joe...@gmail.com

#Frequently Asked Questions

Frequently Asked Questions

Can I have multiple page loaders?

Yes, while you can only register a single page loader when initializing GWT Pages, you can use com.google.gwt.gwtpages.client.page.loader.CompositePageLoader to combine multiple page loaders into 1. This is useful for splitting up pages into logical groups or providing different loading behaviors for different pages.

Can different pages have different layouts?

Yes, again, you can you register a single application presenter when initializing GWT Pages, you can use a composite application presenter to do this. There are a few provided types of these depending or your needs (and you can always roll your own). See the docs for details

  • com.google.gwt.gwtpages.client.page.CompositeApplicationPresenter
  • com.google.gwt.gwtpages.client.page.CompositeLayoutApplicationPresenter

Can I pass data to a page request that doesn't go in the history token?

Yes - every page request has a PageRequestSession associated with it. Anything you add to the session is transient and will not be included in the history token.

  GotoPageCommand cmd = pages.gotoPage("foo", "historyTokenParam1");
  cmd.getSession().put("foo", "bar"); // this will not be in the history token
  cmd.execute();

How do I show a success message when transitioning to a new page?

You can use the same PageRequestSession we just mentioned. If you have used the Pages.addDefaultEventHandlers(), application messaging is provided for you using the Messages class. Here is a simple example:

  PageRequestSessionWithMessage session = new PageRequestSessionWithMessage("your success message");
  pages.gotoPage("foo", session, "historyTokenParam1").execute();

See the next question about setting up the UI for message handling...

Is there an easy way to deal with application messages?

Yes, but it is not directly coupled with Pages - you can use it if you want but don't have to. You need to register the DefaultMessageHandler which you can do easily by calling Pages.addDefaultEventHandlers().

This allows you to call the methods on Messages which have many convenience methods for adding success, warn, error and info messages. Ultimately, these messages are passed around your application using the MessageChangeEvent but there is a component you can just stick in your app to get up and running quickly. Simply add com.google.gwt.gwtpages.client.message.ui.MessagePanel to your application. You would normally add this to the layout so there is a single instance of this but it is not required.

How can I get the event bus that GWT Pages uses?

Every interface used by GWT Pages has an init(Pages) method. In here you can all getEventBus() on the Pages instance - or, if you are using Pages as a singleton (which you most likely are) you can call Pages.get().getEventBus() anywhere in your application.

If you are using GIN, and your Module extends PagesModule, you just need the following code in your page:

  @Inject
  HandlerManager eventBus;
Powered by Google Project Hosting