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