This is more of a GWT question than a GAE question, but I agree that you're
missing the point. An async callback is executed asynchronously (hence the
name), and it looks like you're trying to treat it as if it happens
synchronously:
ContactService.getoneContact(String Name,new AsyncCallback<String>()>
{
public void onFailure(Throwable error) {
PhoneResult="ERROR";
}
public void onSuccess(String Phone) {
// This code is not executed until after the server returns a
response.
// You need to put the code that handles the response here -
such as posting an event, updating the UI, or otherwise dealing with the
results.
PhoneResult=Phone;
}
});
// This code executes immediately after the RPC begins and almost
guaranteed before it completes. Don't write code that depends upon the RPC
having completed here.
return (Phone);
On Tue, Aug 25, 2009 at 5:57 PM, John V Denley
<[email protected]>wrote:
>
> The following code returns "null" the first time it is run, and then
> returns the previous request on the second time it is called.... can
> anyone see whats going wrong? Surely it should wait until it gets the
> server response before returning a value? or am I missing the point
> here?
>
> private String GetOneContact(String Name) {
> //ContactService = GWT.create(ContactService.class);
> ContactService.getoneContact(Name,new AsyncCallback<String>()
> {
>
> public void onFailure(Throwable error) {
> PhoneResult="ERROR";
> }
> public void onSuccess(String Phone) {
> PhoneResult=Phone;
> }
> });
> return (Phone);
> }
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" 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-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---