Thank you for your help!!!

On Apr 16, 5:06 am, Salvador Diaz <[email protected]> wrote:
> If you really really want for some code to be executed when the RPC
> call returns then you're forced to put that code in the onSuccess
> method of your callback, there's no other way around it.
>
> On Apr 15, 10:22 pm, badgerduke <[email protected]> wrote:
>
> > Hello:
>
> > Just started using GWT and I am having difficult tailoring my code to
> > theasynchronousnature of RPC calls.  Specifically, my code asks for
> > the results of an RPC call before anything is returned.
>
> > Here is my class which calls a service.  Instead of using an inner
> > class for the AsyncCallback, I use a separate implementation,
> > FormAsyncCallback, whose code is also below:
>
> > package com.gallup.client;
>
> > import com.google.gwt.core.client.GWT;
> > import com.google.gwt.user.client.rpc.AsyncCallback;
> > import com.google.gwt.user.client.rpc.ServiceDefTarget;
>
> > public class FormService {
>
> >         public String call(FormBean formBean) throws FormException{
>
> >                 FormRemoteServiceAsync serviceProxy = 
> > (FormRemoteServiceAsync)
> > GWT.create(FormRemoteService.class);
> >                 ServiceDefTarget target = (ServiceDefTarget) serviceProxy;
>
> >                 String serviceURL = GWT.getModuleBaseURL() + "formservice";
> >                 if (GWT.isScript()) {
> >                         serviceURL = "/Struts2GWT/formservice";
> >                 }
> >                 target.setServiceEntryPoint(serviceURL);
>
> >                 final String successMessage = null;
>
> >                 FormAsyncCallback callback = new FormAsyncCallback();
>
> >                 serviceProxy.setForm(formBean, callback);
>
> >                 if (!callback.isHadError()) {
> >                         GWT.log("AAAAA", null);
> >                         return callback.getSuccessMessage();
> >                 }
> >                 else {
> >                         throw new FormException(callback.getErrorMessage());
> >                 }
> >         }
>
> > }
>
> > package com.gallup.client;
>
> > import com.google.gwt.core.client.GWT;
> > import com.google.gwt.user.client.rpc.AsyncCallback;
>
> > public class FormAsyncCallback implements AsyncCallback {
>
> >         private String successMessage = null;
> >         private boolean hadError = false;
> >         private String errorMessage = null;
>
> >         public void onFailure(Throwable t) {
> >                 hadError = true;
> >                 GWT.log("BBBBBBBB", null);
> >                 errorMessage = t.getMessage();
> >         }
>
> >         public void onSuccess(Object result) {
> >                 GWT.log("CCCCCCCCC", null);
> >                 successMessage = (String) result;
>
> >         }
>
> >         public String getSuccessMessage() {
> >                 return successMessage;
> >         }
>
> >         public boolean isHadError() {
> >                 return hadError;
> >         }
>
> >         public String getErrorMessage() {
> >                 return errorMessage;
> >         }
> >         public boolean isReturned() {
> >                 return returned;
> >         }
>
> > }
>
> > My problem is that "AAAAAAA"  always prints before "BBBBB" or
> > "CCCCCCC".   I really want my code to wait for the RPC call to return
> > before I interrogate the results.  Does anybody have suggestions?
>
> > Thanks
> > Eric
--~--~---------~--~----~------------~-------~--~----~
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