The example is uses anonymous or local classes which are convenient for many, but there is no reason that you can't create a regular sub- class, or instantiate it as a class member, to use for the async callback anywhere within a given class multiple times.
private class MyCb implements AsyncCallback<StockPrice[]> ... or private AsyncCallback<StockPrice[]> myCb = new AsyncCallback<StockPrice[]>() ... You could also make those static, but then of course they would not have access to other class members. On Apr 7, 3:49 am, FB <[email protected]> wrote: > Hello, > > I'm new on GWT... I'm reading the tutorial (form GWT site) about > "making the remote procedure call", and I read that code: > > private void refreshWatchList() { > > ..... > > // Set up the callback object. > AsyncCallback<StockPrice[]> callback = new > AsyncCallback<StockPrice[]>() { > public void onFailure(Throwable caught) { > // TODO: Do something with errors. > } > > public void onSuccess(StockPrice[] result) { > > updateTable(result); // RUN THIS SPECIFIC METHOD > > } > }; > > ..... > > My question is: it is possible to avoid to have one callBack object > for each method to run? > For example, can I define the callBack Object as Static and use it > multiple times? > > Which is the best way to avoid one callBack object for each method to > run? > > Thank you to all! -- 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.
