On Wed, Mar 18, 2009 at 9:38 PM, [email protected] <[email protected]> wrote: > is there a way to force callback to be excuted before next line?
Nope. See here: http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/faca1575f306ba0f/3be719c021aa19bd One option is to define a new callback interface and pass an instance to GetData. That way you can define the instance in the "other file" and still be a good browser citizen. For example: public interface SearchResultListener { void onNewSearchResult(String result); } public class GetData { public void search(String query, final SearchResultListener listener) { String url = URL.encode(DEFAULT_URL + "?query=" + query); RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url); builder.setCallback(new RequestCallback() { public void onError(Request request, Throwable exception) { // handle problems here } public void onResponseReceived(Request request, Response response) { if (Response.SC_OK == response.getStatusCode()) { listener.onNewSearchResult(response.getText()); } else { // handle problems here } } }); try { builder.send(); } catch (RequestException e) { // handle problems here } } } Then, if you have an instance of GetData, you can do this: aGetData.search("query", new SearchResultListener() { public void onNewSearchResult(String result) { System.out.println(result); } }); Ian --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
