Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gwt multi-page application

Tags:

gwt

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 learning from the Google code and online forums but could not find any application which had multi-pages not linked by a common entry-point. Any ideas?

like image 416
user477469 Avatar asked May 12 '11 21:05

user477469


People also ask

How many important parts are there in a typical GWT application?

A GWT application consists of following four important parts out of which last part is optional but first three parts are mandatory. Sample locations of different parts of a typical gwt application HelloWord will be as shown below −

What are the public resources of GWT application?

When you compile your application into JavaScript, all the files that can be found on your public path are copied to the module's output directory. The most important public resource is host page which is used to invoke actual GWT application.

What is the default module descriptor file extension for a GWT?

A module descriptor file extension is *.gwt.xml, where * is the name of the application and this file should reside in the project's root. Following will be a default module descriptor HelloWorld.gwt.xml for a HelloWorld application −

What is the GWT source code?

This is the actual Java code written implementing the business logic of the application and that the GWT compiler translates into JavaScript, which will eventually run inside the browser. The location of these resources can be configured using <source path = "path" /> element in module configuration file.


2 Answers

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.

  1. Enable history support by adding an iframe to your host page:

    <iframe src="javascript:''" 
            id="__gwt_historyFrame" 
            style="width:0;height:0;border:0">
    </iframe>
    
  2. Register a ValueChangeHandler to be notified when FI (page) changes: History.addValueChangeHandler(..). Within this handler you put a logic that displays the new page.

  3. Go to a particular page by calling History.newItem("newpage") (without #)

  4. 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.

like image 100
Peter Knego Avatar answered Sep 21 '22 12:09

Peter Knego


While you can use GWT to switch pages, the resulting code will be slow and suboptimal, with the pages taking longer to load.

like image 23
Tassos Bassoukos Avatar answered Sep 19 '22 12:09

Tassos Bassoukos