You should only need one html page. This is the main html page that
you already have in your project. If you have done swing work, think
of that html page as your JFrame if you will.
I'll run through a simple example that should at least get you on your
feet.
Your html page could define the basic skeleton layout of your app, say
a header at the top, a panel of your links right under it, and the
rest of the bottom portion of the page is content that will change
dynamically depending on the link clicked.
In your html page you could define <div>'s that define where these
panels will go and give them an identifier id.
<div class="header" id="header"></div>
<div class="linksPanel" id="linksPanel"></div>
<div class="contentPanel" id="contentPanel"></div>
In your corresponding css file, add the necessary definitions to
layout your page, size, borders, etc of each div.
First you could create a class called MyContentPanel. It could be a
singleton with static methods of getInstance() and replaceContent().
This was you will have 1 content panel you can access statically.
public class MyContentPanel extends VerticalPanel
{
private static MyContentPanel INSTANCE = null;
// do not allow outside instantiation
private MyContentPanel()
{
//do layout panel stuff etc
}
public synchronized static MyContentPanel getInstance()
{
if (INSTANCE==null)
INSTANCE = new MyContentPanel();
return INSTANCE;
}
public static void replaceContent(Widget widget)
{
MyContentPanel content = getInstance();
..
remove all current children using getWidgetCount and remove(int)
or remove(Widget)
..
content.add(widget);
}
}
For your link section, you could create a class called MyLinkPanel
that extends Composite (or maybe HorizontalPanel, etc) that defines
your link panel. You could set up handlers on the links that would be
responsible for firing an event to show a particular page in the
MyContentPanel.
Lets say when you click link1, it needs to show a particular page in
the ContentPanel. Well, create your page again as a class that extends
again, Composite or some panel or whatever. Lets say we call it
MyLoginPage. On the handler on link1 could make a static call to pop
it on the content panel like so:
MyContentPanel.replaceContent(new MyLoginPage());
Lets say your app is called MyApp, you will have a MyApp.java file
that implements EntryPoint where you will implement the method
onModuleLoad(). This would be responsible do initializing your app by
public class MyApp implements EntryPoint
{
public void onModuleLoad( )
{
RootPanel.get("header").add(new HeaderPanel());
RootPanel.get("linkPanel").add(new MyLinkPanel());
// add the singleton panel to the contentPanel div
RootPanel.get("contentPanel").add(ContentPanel.getInstance());
}
}
Now that the framework is defined, you can just create new panels
instead of HTML pages and put them in the content panel by calling the
static ContentPanel.replaceContent(widget) method.
Remember, think java, not html. It's kind of why GWT was invented :)