Welcome to the async world! ;-)

I had the same problem. Since the code of an async callback is not
executed in the order of the statements in your myMethod() you can not
directly return the results from onSuccess() in myMethod(). And
myMethod() is not able to "wait" for onSuccess().

You could for example do the things you want to do with
ArrayList<String> in onSuccess() instead of where you call myMethod()
of if you want to keep the processing logic for ArrayList<String>
where myMethod() is called use a method to pass ArrayList<String> from
onSuccess().

You can think of it as separating the logic in two methods:
1) first one does initial stuff and then requests something via RPC
(in your example via myMethod() but with return type void)
2) second one is called by onSuccess() passing the results of the RPC
and continues with the requested data where first method "ends"

Hope it helps,

Andreas

On 2 Jul., 14:50, day_trader <mwmcmul...@gmail.com> wrote:
> At present, an AsyncCallback contains a 'public void onSuccess()'
> method. This is posing significant problems for me at the moment.
>
> I have a method myMethod() being called which has a return value type
> of ArrayList<String>. MyMethod contains this AsynCallback which is
> used to query a database on the server side of the code. I need to,
> either somehow make the method WAIT for the AsyncCallback's
> onSuccess() method to return which is the thing that is giving me the
> ArrayList<String> to return to the code which called myMethod, or
> change the return type of the AsyncCallback to ArrayList<String> and
> let this be the 'return' of myMethod.
>
> Is this possible? Am I very confused? Could someone please advise?

-- 
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-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to