thx both of us: to be sure i understand your suggestion: using list.add also "adds" to the list given in constructor? i know it's probably a java-noob question but why it is different to onSuccess ... list = result ? (besides that this isn't working ;-))
On 11 Apr., 14:55, Magno Machado <magn...@gmail.com> wrote: > try this: > public class ListLoaderAsyncCallback<T> implements > AsyncCallback<ArrayList<T>> { > private final List<T> list; > public ListLoaderAsyncCallback(List<T> list) { > this.list = list; > } > public void onSuccess(ArrayList<T> result) { > list.clear(); > list.addAll(result); > } > public void onFailure(Throwable caught) { > ... > } > > } > > List<SomeType> myList = ....; > MyServiceAsync service = ........; > service.loadSomeData(new ListLoaderAsyncCallback<SomeType>(myList)); > > > > > > > > > > On Mon, Apr 11, 2011 at 9:00 AM, tanteanni <tantea...@hotmail.com> wrote: > > i am fairly new to gwt and struggling some how on "correct"/"nice" RPC > > implementation (it is working but code becomes ugly). On my first GWT > > based apps i often load some lists/data from db into front end. (Lists > > to be used in combo boxes for instance). > > > so if i have a widget that needs 3 different lists (probably > > List<String> or Map<String, String>) i specify a service-method for > > each list. the problem is to load all those lists, i have to implement > > one class (...implements AsyncCallback) for each list. > > but the only difference between this implementations is that they load > > the result in different lists: > > public void onSuccess(){ > > list1 = result > > } > > > so how to implement an abstract callback class that could load its > > "result" into a given list/object (- a field of mother class) > > > (if "call by reference" would exist in java i would giv "list1" as an > > parameter for constructor and onSucces would load the result into this > > reference?!) > > > an optimal implementation would be if the result type could be a > > generic type: A class lie this: > > > class GeneralCallback<T> implements AsyncCallback<T>{ > > public GeneralCallback(T target){ > > ... > > } > > > public onSuccess(T result){ > > target = result; > > } > > } > > > is it possible to get such an abstract callback class? > > > -- > > 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-toolkit@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. > > -- > Magno Machado > Paulohttp://blog.magnomachado.com.brhttp://code.google.com/p/emballo/ -- 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-toolkit@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.