Creating a second page

32 views
Skip to first unread message

Blake

unread,
Dec 24, 2011, 12:04:34 PM12/24/11
to Google Web Toolkit
Greetings,

I'm new to GWT so I appreciate you bearing with me. I've spent a
bunch of hours with GWT & eclipse. I can easily create an app, add
controls, and deal with events. The problem I am having is
understanding how to get to a second (or third...) page. Let's say a
user enters some data on the page and clicks "Submit". I want to do
something with the data and then present a new screen - you know - the
next step of the app. I am hard pressed to find an example showing
how to go to a second page.

I have a bunch of books on the subject but most of them are either
very out-of-date or they too don't show how to do this simple task. I
did read one sentence in a book that said that a GWT app uses the same
page but just clears and re-fills it (or one of its panes) rather than
loading a new page. If this is true I think it's a good thing. So, I
need to know two things:

1. How do I define a second page using the eclipse GWT designer?

2. How do I get one page to call the other?

Thanks.

Blake McBride

Ed

unread,
Dec 25, 2011, 8:17:22 AM12/25/11
to google-we...@googlegroups.com
I don't use GWT designer and probably will never do, like most people that are building a long time with GWT.
Don't get me wrong: it's a great tool, but like with all visual designer tools: with experience comes detail requirements that can't be done through a designer tool.
Anyway, some advice on how to do it without designer:
Take a SimpleWidget panel, add that to the body, or other html element and wen you want to go to another page simple replace the widget in SimpleWidget.
in pseudo code:
SimpleWidget outer = new SimpleWidget();
RootPanel.get("pageId").add(outer);
outer.setWidget(page1); // showing page 1
...
going to  page 2 some where in code:
outer.setWidget(page2); // showing page 2

Just put this outer panel in a central Register (Singleton class) such that it can be reached from anywhere and you are done...

Then if you want, add to some Fade In/Out effect when adding page1 and page2... Do this ina  transparent way such that the code that add's page X won't see this... 
Fade effects looks so much better and professional when navigating. I always do it by wrapping any GWT Panel through my own panel such that the user that adds a widget to the panel won't notice the effect as it's a property of the panel... 
BTW: wrapping a panel is also good for testing..., see: https://groups.google.com/forum/#!topic/google-web-toolkit/hwMKmuZv4BI






Reply all
Reply to author
Forward
0 new messages