I have a multipage application which needs to manually switched from one page to another. could it be done in GWT since it is targeted towards single page application. I am
GWT has support for "pages" within application via URL fragment identifier (FI), i.e. http://www.yourhost.vom/main#pagename
, where "pagename" is a fragment identifier representing a "page" within your app.
This "pages" (note that browser never really reloads the page, so GWT app stays the same), have full history support and are bookmarkable.
NOTE: throughout GWT docs fragment identifier is sometimes referred to as place token or history token.
Enable history support by adding an iframe to your host page:
Register a ValueChangeHandler to be notified when FI (page) changes: History.addValueChangeHandler(..)
. Within this handler you put a logic that displays the new page.
Go to a particular page by calling History.newItem("newpage")
(without #)
You can even pass "parameters" to page, by dividing fragment identifier into sub parts: for example "#edit/user4". Just parse this FI, invoke code that shows edit page and pass "user4" to it. You can use any character to divide FI into a "page" part and "parameter" part (I use "/" here). To see this in real life: open a message in gmail and look at URL.