Oh, BTW, you would need to move your call to logToServer into the
onSuccess as well. I didn't notice that one at first.

HTH,
Chad

On Jun 8, 2:28 pm, Chad <chad...@gmail.com> wrote:
> You don't want to block the UI with a while loop. Instead, consider
> creating an interface with a single method:
>
> public interface LoginCallback {
>   void onLogin(int feedback);
>
> }
>
> Then, alter your loginUser method to return void and take as an
> addition parameter a LoginCallback:
>
> public void loginUser(String user, String passwd, boolean override,
> final LoginCallback cb) {
>   XGENgwt.loginUser(user, passwd, override, new AsyncCallback() {
>     public void onSuccess(Object result) {
>       cb.onLogin(Integer.parseInt(result.toString()));
>     }
>
>     public void onFailure (Throwable caught) {
>       Window.alert("Unable to login: "+caught.toString());
>     }
>   });
>
>   logToServer("Bei der Zuweisung: "+loginFeedback);
>
> }
>
> You could also call the onLogin from the onFailure if you wanted to.
> Or create an addition method in your LoginCallback to call from the
> onFailure.
>
> Take the code that currently follows the call to your loginUser method
> and move it into the onLogin method of an instance of LoginCallback
> that gets passed to the new loginUser method. Think Async! ;-)
>
> HTH,
> Chad
>
> On Jun 8, 8:07 am, uwi_u <uwe.chris...@gad.de> wrote:
>
>
>
> > Hi there,
>
> > I'm currently writing an Application with GWT, and am Stuck at one
> > position:
>
> > When I call my RPC, the value which is to be returned, will be passed
> > to an global variable. Unfortunately, the returning of this global
> > variable out of the method happens before the onSuccess comes
> > back.....
>
> > the only way to block which I see is to do a while until "
> > loginFeedback < 0"
>
> > Heres some Code (loginFeedback shall get a value from 0 to 2):
>
> > public int loginUser(String user, String passwd, boolean override){
> >           loginFeedback = -1;
> >           XGENgwt.loginUser(user, passwd, override, new AsyncCallback(){
> >                 public void onSuccess(Object result){
> >                   loginFeedback = Integer.parseInt(result.toString());
> >                 }
> >                 public void onFailure (Throwable caught){
> >                   Window.alert("Unable to login: "+caught.toString());
> >                 }
> >           });
> >           logToServer("Bei der Zuweisung: "+loginFeedback);
> >           return loginFeedback;
> >         }
>
> > Is there a better way? I hope so....

-- 
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