How to load data BEFORE showing view/presenter?

61 views
Skip to first unread message

Matt H

unread,
Nov 30, 2010, 8:27:14 PM11/30/10
to Google Web Toolkit
Hi.

If you poke around some of Google's GWT apps, you'll find that when
you click on anything which requires more data to be loaded, that a
'loading' sign is displayed at the top of the screen, and while
loading, it stays on the current view, and then when the data for the
next view has been downloaded, the loading sign is removed and the new
view is shown.

How can I implement this behavior?

Matt H

unread,
Dec 1, 2010, 1:01:09 PM12/1/10
to Google Web Toolkit
Anyone? Surely it's simple enough to do?

ep

unread,
Dec 1, 2010, 3:22:56 PM12/1/10
to Google Web Toolkit
depends on the MVP framework you use - gwtp for instance, already
supports it, if GWT MVP does not, then you can subclass presenter,
call it "IndicatingPresenter" and add one more lifecycle state,
because the presenter will be lazy loaded and shows a loading
indicator until its data is not available... when ready re-render the
view with data loaded.

Matthew Hill

unread,
Dec 1, 2010, 4:28:17 PM12/1/10
to google-we...@googlegroups.com
Sorry, I should've mentioned that I'm using GWT 2.1 Activities + Places.


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


metalhammer29a

unread,
Dec 1, 2010, 4:39:34 PM12/1/10
to Google Web Toolkit
I do not know the answer to this.
and would like to find out as I am in the similar situation.

However I have come across this class:
com.google.gwt.requestfactory.shared.RequestEvent

http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/gwt/requestfactory/shared/RequestEvent.html

http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/requestfactory/shared/RequestEvent.java?r=9033

and from Expenses app generated by Roo,
I can see it is used like below:

RequestEvent.register(eventBus, new RequestEvent.Handler() {
// Only show loading status if a request isn't serviced in
250ms.
private static final int LOADING_TIMEOUT = 250;

public void onRequestEvent(RequestEvent requestEvent) {
if (requestEvent.getState() == RequestEvent.State.SENT)
{
shell.getMole().showDelayed(LOADING_TIMEOUT);
} else {
shell.getMole().hide();
}
}
});

in UiBinder:
<g:NotificationMole animationDuration='0' message='loading...'
ui:field='mole'></g:NotificationMole>

in UiBinder java class:
@UiField NotificationMole mole;

NoticiationMole:
http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/gwt/user/client/ui/NotificationMole.html

these are the pieces I have found.
but haven't put them together myself.

metalhammer29a

unread,
Dec 1, 2010, 4:41:42 PM12/1/10
to Google Web Toolkit
sorry, I believe I misunderstood your question.

Thomas Broyer

unread,
Dec 2, 2010, 8:53:36 PM12/2/10
to Google Web Toolkit
The trick is that the AcceptsOneWidget that you use for your
ActivityManager has to handle a 'null' value as *not* clearing the
display (in other words, give an AcceptsOneWidget of your own, do not
use a SimplePanel).
ActivityManager calls setWidget(null) when it stops the current
activity, and the next activity will then call setWidget with its view
when it's ready. If, when called with null, you don't do anything, the
previous activity will still be shown. And in your activities then
only call setWidget once you received the data.

The "loading" text is another story, and depends how you retrieve your
data; but metalhammer29a rightfully pointed to the NotificationMole
for the "display" part.

Matthew Hill

unread,
Dec 2, 2010, 9:03:14 PM12/2/10
to google-we...@googlegroups.com
Thank you Thomas, that sounds very promising. I'll try that out.

Reply all
Reply to author
Forward
0 new messages