Chris Norris
Chris Norris

Reputation: 161

Multiple Page Development in Java with Eclipse and GWT

I have been writing some basic code for an application I am designing. I have learned the basics and gotten some simple database connection working with RPC calls etc. What I need to do now and am completely lost (as I am traditionally a c# developer with windows forms).

In c# if I wanted a new form I would just create it, and then call the show method.

How does one create multiple pages in GWT, and switch between them?

Thanks in advance, Chris

Upvotes: 1

Views: 449

Answers (3)

Athanasios Kataras
Athanasios Kataras

Reputation: 26450

The simplest way would be to

  1. Make a new java class (GwtHome.java, GwtHelp.java etc)
  2. Extend these classes by using the Composite class
  3. Make the equivalent of a Master Page and add it to the rootPanel as a class with the appropriate headers, menu, footer and Content Placeholder (Could be any of the AbsolutePanel, VerticalPanel, HorizontalPanel objects provided by the GWT Framework)
  4. By clicking on the menu clear the Placeholder and add the appropriate object of GwtHome, GwtHelp etc.

After getting aquanted with the above procedure, you might want to break up the code in many files using a design pattern as suggested by Andrei.

Upvotes: 2

Andrei Volgin
Andrei Volgin

Reputation: 41099

Look at Activities and Places design pattern: https://developers.google.com/web-toolkit/doc/latest/DevGuideMvpActivitiesAndPlaces

I highly recommend it for a multipage GWT app. It explains pretty well how you create different "views", that are driven by their "activities", and tied to specific "places" (pages) that users can navigate.

Typically you use a LayoutPanel as your "page" container that occupies the entire available browser window. You split this LayoutPanel into 2-3 layers (zones), like top menu, side menu, main area. Each area contains one widget, usually a ScrollPanel, FlowPanel, or HtmlPanel. Then you use different widgets or HTML inside each of these widgets to display whatever you need. You may also create your own composite widgets that you can reuse in different pages.

Upvotes: 1

João Mendes
João Mendes

Reputation: 1435

Simply clear the root panel (RootPanel.get().clear()) and add the widget for your new "page", the same way you added your first one.

If you're using LayoutPanels, do RootLayoutPanel.get().clear() instead.

Upvotes: 1

Related Questions