Re: need more abstract AsyncCallback class
that doesn't work either :-|. I need something that works on all collections. Do i need a ? somewhere probably? On 11 Apr., 16:52, Magno Machado magn...@gmail.com wrote: Try this: class LoadMapsE, T extends CollectionE implements AsyncCallbackT { On Mon, Apr 11, 2011 at 11:43 AM, tanteanni tantea...@hotmail.com wrote: meanwhile i tried your suggestions but i am struggling at getting the right signature: so i want a callback working of all kinds of collections and adding the result to the given collection: at the moment i got this: private class LoadMapsT extends Collection implements AsyncCallbackT { private T target; protected LoadMaps(T whereTo) { target = whereTo; } @Override public void onFailure(Throwable caught) { Window.alert(caught.getMessage()); } @Override public void onSuccess(T result) { target.addAll(result); } } the only problem is now: i can't call the constructor: MapString, ListString myMap = new HashMapString, ListString(); LoadMaps loadMaps = new LoadMaps(myMap); --The constructor AdminUnits.LoadMaps(TaskDoneEvent, MapString,ListString) is undefined besides this i get Type safety: The method addAll(Collection) belongs to the raw type Collection. References to generic type CollectionE should be parameterized in LoadMaps-onSuccess-target.addAll(result) so how to fix this On 11 Apr., 14:00, 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 ListString or MapString, 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 GeneralCallbackT implements AsyncCallbackT{ 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.
Re: need more abstract AsyncCallback class
ok my fault - i tried to use a map - and map isn't a collection. stupid me On 12 Apr., 08:05, tanteanni tantea...@hotmail.com wrote: that doesn't work either :-|. I need something that works on all collections. Do i need a ? somewhere probably? On 11 Apr., 16:52, Magno Machado magn...@gmail.com wrote: Try this: class LoadMapsE, T extends CollectionE implements AsyncCallbackT { On Mon, Apr 11, 2011 at 11:43 AM, tanteanni tantea...@hotmail.com wrote: meanwhile i tried your suggestions but i am struggling at getting the right signature: so i want a callback working of all kinds of collections and adding the result to the given collection: at the moment i got this: private class LoadMapsT extends Collection implements AsyncCallbackT { private T target; protected LoadMaps(T whereTo) { target = whereTo; } @Override public void onFailure(Throwable caught) { Window.alert(caught.getMessage()); } @Override public void onSuccess(T result) { target.addAll(result); } } the only problem is now: i can't call the constructor: MapString, ListString myMap = new HashMapString, ListString(); LoadMaps loadMaps = new LoadMaps(myMap); --The constructor AdminUnits.LoadMaps(TaskDoneEvent, MapString,ListString) is undefined besides this i get Type safety: The method addAll(Collection) belongs to the raw type Collection. References to generic type CollectionE should be parameterized in LoadMaps-onSuccess-target.addAll(result) so how to fix this On 11 Apr., 14:00, 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 ListString or MapString, 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 GeneralCallbackT implements AsyncCallbackT{ 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.
Re: need more abstract AsyncCallback class
now it is working nearly perfect - only some raw type warnings remain - how to get rid of them? my signature look now like this: private class LoadMapsT extends Map implements AsyncCallbackT i get 2 raw type warnings - one in signature. this one i can eliminate by adding Map?,? but then target.putAll(result) isn't working anymore. so how to distribute ? correctly? On 11 Apr., 14:00, 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 ListString or MapString, 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 GeneralCallbackT implements AsyncCallbackT{ 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.
Re: need more abstract AsyncCallback class
i got it - it is similar with collections: private static class LoadMapsK,V implements AsyncCallbackMapK,V { private MapK,V target; protected LoadMaps(TaskDoneEvent ev, MapK,V whereTo) { target = whereTo; } @Override public void onFailure(Throwable caught) { Window.alert(caught.getMessage()); } @Override public void onSuccess(MapK,V result) { target.putAll(result); } } thx to both of you! On 11 Apr., 14:00, 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 ListString or MapString, 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 GeneralCallbackT implements AsyncCallbackT{ 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.
Re: need more abstract AsyncCallback class
try this: public class ListLoaderAsyncCallbackT implements AsyncCallbackArrayListT { private final ListT list; public ListLoaderAsyncCallback(ListT list) { this.list = list; } public void onSuccess(ArrayListT result) { list.clear(); list.addAll(result); } public void onFailure(Throwable caught) { ... } } ListSomeType myList = ; MyServiceAsync service = ; service.loadSomeData(new ListLoaderAsyncCallbackSomeType(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 ListString or MapString, 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 GeneralCallbackT implements AsyncCallbackT{ 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 Paulo http://blog.magnomachado.com.br http://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.
Re: need more abstract AsyncCallback class
On Mon, Apr 11, 2011 at 8:00 AM, tanteanni tantea...@hotmail.com wrote: an optimal implementation would be if the result type could be a generic type: A class lie this: class GeneralCallbackT implements AsyncCallbackT{ public GeneralCallback(T target){ ... } public onSuccess(T result){ target = result; } } is it possible to get such an abstract callback class? Sounds more like you would want an implementation that looked like: class CollectionLoadingCallbackT implements AsyncCallbackT { private final CollectionT col; public CollectionLoadingCallback(CollectionT col) { this.col = col; } public void onSuccess(T result) { col.add(result); } ... } Of course, I'm sure you'd want another callback to actually know when the value was received, but the general idea above would work. -- 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.
Re: need more abstract AsyncCallback class
D'oh! Looks like the offline gmail worked against me. :) Late posting a duplicate suggestion, and I meant to edit it. I was going to say it might be worthwhile to use TakesValueT instead of collection, so you can get the callback semantics in there. -- 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.
Re: need more abstract AsyncCallback class
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 ListLoaderAsyncCallbackT implements AsyncCallbackArrayListT { private final ListT list; public ListLoaderAsyncCallback(ListT list) { this.list = list; } public void onSuccess(ArrayListT result) { list.clear(); list.addAll(result); } public void onFailure(Throwable caught) { ... } } ListSomeType myList = ; MyServiceAsync service = ; service.loadSomeData(new ListLoaderAsyncCallbackSomeType(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 ListString or MapString, 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 GeneralCallbackT implements AsyncCallbackT{ 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.
Re: need more abstract AsyncCallback class
why it is different to onSuccess ... list = result ? (besides that this isn't working ;-)) 1. list = result implies that your callback has a reference to the object that is holding the list. Maybe it would be a problem for you, maybe not 2. list = result will make the list variable point to a new object. If you have any other object holding a reference to the previous list object, it will still point to that object after the assignment, so it won't see the objects that came from the rpc call On Mon, Apr 11, 2011 at 10:44 AM, tanteanni tantea...@hotmail.com wrote: 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 ListLoaderAsyncCallbackT implements AsyncCallbackArrayListT { private final ListT list; public ListLoaderAsyncCallback(ListT list) { this.list = list; } public void onSuccess(ArrayListT result) { list.clear(); list.addAll(result); } public void onFailure(Throwable caught) { ... } } ListSomeType myList = ; MyServiceAsync service = ; service.loadSomeData(new ListLoaderAsyncCallbackSomeType(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 ListString or MapString, 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 GeneralCallbackT implements AsyncCallbackT{ 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. -- Magno Machado Paulo http://blog.magnomachado.com.br http://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.
Re: need more abstract AsyncCallback class
On Mon, Apr 11, 2011 at 9:44 AM, tanteanni tantea...@hotmail.com wrote: 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 ;-)) Wow... this is so much easier to describe with paper and some drawings. :) You were on to it with the by-value versus by-reference question. By passing the collection, anyone can add to it if they have a copy of your reference. What they can not do is modify the original reference to point to a new collection. -- 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.
Re: need more abstract AsyncCallback class
Try this: class LoadMapsE, T extends CollectionE implements AsyncCallbackT { On Mon, Apr 11, 2011 at 11:43 AM, tanteanni tantea...@hotmail.com wrote: meanwhile i tried your suggestions but i am struggling at getting the right signature: so i want a callback working of all kinds of collections and adding the result to the given collection: at the moment i got this: private class LoadMapsT extends Collection implements AsyncCallbackT { private T target; protected LoadMaps(T whereTo) { target = whereTo; } @Override public void onFailure(Throwable caught) { Window.alert(caught.getMessage()); } @Override public void onSuccess(T result) { target.addAll(result); } } the only problem is now: i can't call the constructor: MapString, ListString myMap = new HashMapString, ListString(); LoadMaps loadMaps = new LoadMaps(myMap); --The constructor AdminUnits.LoadMaps(TaskDoneEvent, MapString,ListString) is undefined besides this i get Type safety: The method addAll(Collection) belongs to the raw type Collection. References to generic type CollectionE should be parameterized in LoadMaps-onSuccess-target.addAll(result) so how to fix this On 11 Apr., 14:00, 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 ListString or MapString, 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 GeneralCallbackT implements AsyncCallbackT{ 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 Paulo http://blog.magnomachado.com.br http://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.