Try this:
class LoadMaps<E, T extends Collection<E> implements
AsyncCallback<T> {

On Mon, Apr 11, 2011 at 11:43 AM, tanteanni <[email protected]> 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 LoadMaps<T extends Collection> implements
> AsyncCallback<T> {
>                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:
> Map<String, List<String>> myMap = new HashMap<String, List<String>>();
> LoadMaps loadMaps = new LoadMaps(myMap);
>
> -->"The constructor AdminUnits.LoadMaps(TaskDoneEvent,
> Map<String,List<String>>) is undefined"
>
> besides this i get "Type safety: The method addAll(Collection) belongs
> to the raw type Collection. References to generic type Collection<E>
> should be parameterized" in LoadMaps->onSuccess->target.addAll(result)
>
> so how to fix this
>
> On 11 Apr., 14:00, tanteanni <[email protected]> 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 [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.
>
>


-- 
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 [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