Reputation: 161
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
Reputation: 26450
The simplest way would be to
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
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
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