Hi Miche_de,

Basically your problems are around not waiting for your first asynch
call to return before issuing the second one (a common error).
doubleuser will aleways be null when you call
getuser.getDefinedUser(vorname.getValue(), callbackFindUser); for the
first time in this situation:

               AsyncCallback<String> callbackFindUser = new
AsyncCallback<String>() {
                        public void onFailure(Throwable caught) {
                                //check error
                        }
                        public void onSuccess(String svar) {
                                doubleuser = svar;
                        }
                };
                getuser.getDefinedUser(vorname.getValue(), callback);

                if (doubleuser == "user found") { <<<<<<<<<<<<<<<<<
always null here!
                        message2.setText("user allreay exists");
                        message2.setVisible(true);
                        return;
                }

However the second time you do it doubleuser has been set by the
previous call so it appears to work. My favourite explanation of this
is by Jason Essington here:

http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/faca1575f306ba0f/3be719c021aa19bd?lnk=gst&q=jason+essington+RPC+beer#3be719c021aa19bd

You could fix this by putting all the code for second call inside a
separate method that you call from the onSuccess(..) of the first
after doubleuser is set. However I agree completely with Lothar that
in this case you should perform all this logic on the server and make
a single call. You could either return an exception as Lothar
suggests, or you could design a Data Transfer Object that came back in
different states depending on the result. Either way you reduce the
number of RPC calls made (which is always good) and also remove some
asynchronous spaghetti from your client side code.

regards
grergor





On Oct 20, 9:05 am, Michi_de <[EMAIL PROTECTED]> wrote:
> Now i just wanted to add one thing: when i try only the other method
> as stand alone, to check for existing strings in the db i have some
> trouble too. I just implement the call to check for existing strings.
> If i find some, a message label apear and tells me that. The thing i
> wounder now is, why its only pop up when i hit the button a second
> time? It seems to me like, it checks for doulbe string but the "if ()"
> is getting checked first. So it first says "if (userfind==true)" and
> then it checks for the db with the string. But i first do this call:
>
>                 getuser.getDefinedUser(vorname.getValue(),
> callbackFindUser);
>
>                 if (doubleuser == "user found") {
>                         message2.setText("user allreay exists");
>                         message2.setVisible(true);
>                         return;
>                 }
>
> First the call, then the "if". So why it only seems to work when i hit
> the button twice?? Any idea?
>
> On 20 Okt., 09:47, Lothar Kimmeringer <[EMAIL PROTECTED]> wrote:
>
>
>
> > Michi_de schrieb:
>
> > > Actually i've some problem with my GWT project. I have some textfield
> > > and a button. Clickin the button, a method starts and write the string
> > > into a mysql database with a servlet. It works wonderfull.
> > > Now i wanted some additional features in this method. I want to search
> > > the database first, for the string, and if it finds a equal string in
> > > my database it should return a error message and NOT put the new
> > > string into the database.
>
> > Extend the first method by throwing an exception in that case.
> > That way you don't need two calls for more or less the same
> > thing. You can throw your own exception by extenting it from
> > SerializableException.
>
> > Regards, Lothar
>
> Thanks for the fast reply.
> So u think i should use only one call? Can u give me some help with
> this exception thingy please? Where exactly to throw an exception? It
> seems rather complex to me, this solution :P ;)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to