When you call loginUser, you will create an instance of
XGENgwtModelCallback (I'm assuming that's what you called
LoginCallback). In that instantiation, you will need to define the
onLogin method:

loginModel.loginUser(user, passwd, false, new XGENgwtModelCallback() {
  @Override
  public void onLogin(int feedback) {
    // Decide what to do using the feedback parameter which contains
your value
  });

If you want to use the same interface for multiple callback types, you
can add methods, but then you'll have to implement them in every case.
So, you will end up implementing methods that won't get called. It's
better to create a specific interface for each type of callback you
need.

HTH,
Chad

On Jun 9, 3:57 am, uwi_u <[email protected]> wrote:
> Thanks a lot,
>
> but I've got further questions .... ;)
>
> I'm using gwt-mvc. So, the described Method is located in the Model.
> What to do in the Controller exactly? After calling loginUser, my
> program decides which way to go by taking the feedback.
> So should I do the following?
>
> loginModel.loginUser(user, passwd, false, new XGENgwtModelCallback(
>    /*  Decide what to do, but how to get the "loginFeedback" */
>
> ));
>
> Thinking Async almost drives my crazy.... :-(
>
> BTW: I've got other methods, which return DB2-SQL-Queries as a
> Vector<Vector<String>>.... I guess, I should rename LoginCallback to
> ModelCallback and add another Method "public void
> onSQLQuery(Vector<Vector<String>> vec)" as well, should I?
>
> On 9 Jun., 00:15, Chad <[email protected]> wrote:
>
>
>
> > 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 <[email protected]> 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 <[email protected]> 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 [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