Hi Jake H,
As far as I can tell, there are two ways to make multiple dependent
remote calls in GWT and have the data come together in one display.
The first is what you suggested in your Dec 18/6:10am post: make a
call to source 1, then in the request call back, make a call to source
2, then in that request call back, make a call to source 3. In other
words, you serialize remote data calls.
The other option is to use a set of marker variables, like:
boolean sourceOneComplete = false , sourceTwoComplete = false ,
sourceThree complete = false ;
in the callbacks, save the data retrieved to variables, set the
appropriate boolean to true, and then call fillData(), or some other
method.
Inside fillData, you have something like this:
if (! (sourceOneComplete && sourceTwoComplete &&
sourceThreeComplete) ) { return; }
.... actually build the display.
Of course, this runs the same possibility of never completing as your
while() loop did; to protect against that, you could use a Timer to
display an error message if things aren't done in a sane period of
time (or you could just choose to display what you had):
Timer t = new Timer() {
public void run() {
if (! (sourceOneComplete && sourceTwoComplete &&
sourceThreeComplete) ) {
// cancel the requests
Window.alert("unable to get
needed data");
}
}
};
t.schedule(5000); // or whatever
Using this strategy will let you parallelize your remote calls (though
you may still be limited by bandwidth and domain name browser
restrictions.
I hope this helps!
Dan
On Dec 18, 6:10 am, jake H <[email protected]> wrote:
> Okay i found a solution :)
>
> "Typically, applications receive asynchronous responses in some sort
> of
> callback method. Java does not have a way of passing method pointers
> around, so it usually accomplishes this through interfaces. The
> provider of
> the asynchronous resource defines a public interface that you would
> implement if you needed an asynchronous response. When asynchronous
> events occur, the event source calls a method on the provided
> interface
> instance."
>
> That means in order to make the application work properly u have to
> call the next requestcallback after the first one finishes. In this
> way u guarantee take the results u want plus there isnt any waiting
> time. ;)
>
> ty all for the replies.
>
> Another solutions are welcome also.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---