Ahhhh, after some investigation, looks like what im doing is
initiating an asynchronous request to the server, and then not waiting
long enough for the reply, hence why im getting the reply whenever i
make the second request....

Can anyone tell me how i can make sure i get the reply ive asked for?
what am i missing here?

Thanks,
John

On Aug 25, 7:30 pm, John V Denley <johnvden...@googlemail.com> wrote:
> OK, after a little further investigation Ive confirmed now that the
> client side function is taking in the correct search name, the problem
> is certainly that the server side appears to be receiving the previous
> request.
>
> Ive changed the returns in both functions such that i now get the
> following:
>
> john:null
> paul:(john)john:1111
> john:(paul)paul:2222
>
> where the format is:
> input to client function : (input to server function):name of found
> contact from query:phone of found contact from query
>
> Thanks,
> John
>
> On Aug 25, 6:23 pm, John V Denley <johnvden...@googlemail.com> wrote:
>
> > Ive implemented the stockwatcher application and have adjusted it so
> > that it stores names and phone numbers. That all seems to be working
> > ok, however Ive now implemented a "get" function which looks for a
> > name, and returns a phone number. However, whats happening is that the
> > first search i do returns nothing, then if i search for the same name
> > again, then it returns the correct phone number, then if i search for
> > another name, it returns the first name's phone instead.
>
> > eg I have the following data in the datastore:
>
> > john 1111
> > paul 2222
>
> > i request the phone number for john and i get back ""
> > I request the phone number for paul and i get back "1111"
> > I request the phone number for john and i get back "2222"
>
> > Client side Java file contains:
>
> >     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 (PhoneResult);
> >     }
>
> > Server side (ContactServiceImpl.java) contains:
>
> >   public String getoneContact(String Name) throws NotLoggedInException
> > {
> >             checkLoggedIn();
> >             String Phone="x";
> >             PersistenceManager pm = getPersistenceManager();
> >             try {
> >                 //Query q = pm.newQuery(Contact.class, "user == u &&
> > Name==n");
> >                 Query q = pm.newQuery(Contact.class, "user == u");
> >                 q.declareParameters("com.google.appengine.api.users.User 
> > u");
> >                 //q.declareParameters("John n");
> >                 List<Contact> Contacts = (List<Contact>) q.execute(getUser
> > ());
> >                       for (Contact contact : Contacts) {
> >                                 if (Name.equals(contact.getName())) 
> > {Phone=contact.getPhone
> > ();}
> >                               }
>
> >             } finally {
> >                 pm.close();
> >               }
> >             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 google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to