RootPanel.get("mainContainer").add(new Label("Array lista 2:
"+lista.toString()));
               RootPanel.get().add(new Label(String.valueOf("Array lista 2:
"+lista.size())));
               for(int i = 0; i < lista.size(); i++){
                       RootPanel.get().add(new Label("BOTON "+i));
               }

esto esta fuera del contexto de asíncrono

 public void onSuccess(ArrayList<String> result) {
 }

ese contrato del AsyncCallback es el que se ejecuta cuando el servidor
regresa el resultado
si ahi tu result esta vacio entonces checa el lado del servidor.
no debes tener problema con lista.addAll(result);  // no addAll(0,x)
ya que esa lista se va a sobreescribir cada llamada al servidor


2011/6/21 Jose Luis Hernandez <jose.hernande...@gmail.com>

> Hello!
> I have a problem. I am calling to server side on GWT. The results of
> call is an ArrayList (result). Inside onSuccess method another
> ArrayList is wrapped with the result. However, if I want to use
> ArrayList lista outside of onSuccess method it contains 0 elements,
> but inside is like result ArrayList. How can I solve it? I have tried
> to use lista as class attribute, static attribute,... but it doesn't
> run.
> Thanks!
>
> public void addContainers() throws Exception {
>                final ArrayList<String> lista = new ArrayList<String>();
>                gwtService.obtainAttributesDevice(1, new
> AsyncCallback<ArrayList<String>>(){
>                        @Override
>                        public void onFailure(Throwable caught) {
>                                System.out.println("ERROR");
>                                Window.alert(caught.getMessage());
>                        }
>                        @Override
>                        public void onSuccess(ArrayList<String> result) {
>                                RootPanel.get("mainContainer").add(new
> Label("Array result:
> "+result.toString()));
>                                RootPanel.get().add(new
> Label(String.valueOf("Array result:
> "+result.size())));
>                                lista.addAll(0, result);
>                                RootPanel.get("mainContainer").add(new
> Label("Array lista 1:
> "+lista.toString()));
>                                RootPanel.get().add(new
> Label(String.valueOf("Array lista 1:
> "+lista.size())));
>                        }
>                });
>                RootPanel.get("mainContainer").add(new Label("Array lista 2:
> "+lista.toString()));
>                RootPanel.get().add(new Label(String.valueOf("Array lista 2:
> "+lista.size())));
>                for(int i = 0; i < lista.size(); i++){
>                        RootPanel.get().add(new Label("BOTON "+i));
>                }
> }
>
> --
> 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.
>
>

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

Reply via email to