What I usually do in such situations is to first develop a web page structure. I will have a div for the title, sidebar and footer. I will also have a div in my HTML for the main content.
Example:
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name='gwt:module' content='org.project.package.Core=org.project.package.Core'> </head> <body> <script language="javascript" src="ui/org.project.package.ui.Core.nocache.js"></script> <table id="wrapper" cellpadding="0" cellspacing="0" style="width: 100%;height: 100%;"> <tr style="height: 25%;"> <td colspan="2" id="header"></td> </tr> <tr style="height: 65%;"> <td id="leftnav"></td> <td id="content"></td> </tr> <tr style="height: 10%;"> <td colspan="2" id="footer"></td> </tr> </table> <iframe id="__gwt_historyFrame" style="width:0;height:0;border:0"></iframe> </body> </html>
(If you like based layouts
Then you create your entry point (in my case Core.java ), as usual, setting each of the elements as needed.
RootPanel.get("header").add(new Header()); RootPanel.get("leftnav").add(new NavigationMenu()); RootPanel.get("footer").add(new Footer());
Of course, it is possible to have a static footer and header, but this is neither here nor there.
I also have an abstract class called "Content". Content objects extend Composite and will have various methods to simplify the creation and layout of a new page. Every page that I create for this application, whether itβs a help screen, a search screen, a shopping cart or something else, is of type Content .
Now I am creating a class called ContentContainer. This is a singleton that is responsible for managing the "content" element. It has one method called "setContent" that accepts objects of type "Content". Then it basically removes something inside the "content" <td> and replaces it with any Composite widgets that you assign using the setContent method. The setContent method also handles header and header control. Basically, the ContentContainer serves to aggregate all the various anchor points that you may need if each page content needs to βknowβ about all the functions that it needs to perform.
Finally, you need a way to get to this page, right? It's simple:
ContentContainer.getInstance().setContent(new Search());
Put the above event in a random press and you will be golden.
The only things your other widgets need to be related is the ContentContainer and the type of content they add.
The disadvantages that I see in the ChrisBo approach are that you have a list that should be maintained in tokens β pages. Another drawback that I see is that I do not see how you can have a real story system with this method.
One thing he suggests in my approach is that all page options are pretty centralized. I would use some kind of Enum, or at least a static class with String values, to prevent me from confusing the links.
In any case, I think that this paragraph can be summarized as follows: replace the contents of some element of the central page based on the fact that your user clicks the actions performed by your user (s).