In GWT requests happen asynchronously (ie. they don't block at the
call point waiting for the server's response) so your draw table is
being executed while your requests are still being sent to the
server.  You have to design your code so that any code dependent on
the results of your server calls is invoked from the RequestCallback.


On Dec 17, 8:50 am, jake H <pnosti...@gmail.com> wrote:
> ok i did something similar to deadlock technique to get the data
> ordered.
> But i still has a problem with the fill in.
>
> What i mean is:
> To avoid having nullpointer in the array i fill it with error msgs.
>
>    for (int i=0; i<arr.length; i++) {
>              for (int j=0; j<arr[i].length; j++) {
>                  arr[i][j] = "error";
>              }
>          }
>
> When RequestCallBack is called, inside i have the 2 well known
> functions extractData that returns an JSONObject and the
> updateResults.
>
> Into update results i call another function , fill_data
>
> private void updateResultsArea(JSONObject results) {
>
>         String value = getString(results.get("value"));
>         fill_data(name,value,counter);
>         increase();
>   }
>
> Name is the url that is parsed every time RequestCallBack is called
> ( This is how i solved the matching part )
> Value is the JsonValue and counter is a global variable , used as a
> counter that is increased every time this function is called , in
> order to save the data respectively.
>
> But after the request messages are over, and i want to draw the
> results in my panel using a draw_table() function , which has inside a
> while loop.  However, when it tries to print the data of the array , i
> get the error msgs instead of the saved data.
>
> This is what i have inside the basic constructor of my class
>
>    array_list.add("Name");
>    array_list.add("L_Name");
>    array_list.add("tel");
>
>         Iterator itr = array_list.iterator();
>         resultsArea.setSize("100%", "100%");
>
>        while(itr.hasNext())
>        {
> // Here i send all json requests, taking back the results and trying
> to save them in an array
>
>         SendJsonRequests(itr.next().toString());
>         }
> // Here i want to use the data i saved in order to draw my
> application
>            draw_table();
>
>             initWidget(resultsArea);
>    }
>
> Now in the draw_table() function
> By putting a Window.alert() msg , lets call it magic? dont know , but
> the results are printed fine.
> By comment window.alert() msg,  all saved data is gone and error msgs
> are printed!
>
>  private void draw_table()
>    {
>         int c2 = 0;
>
>         while( c2 < arr.length )
>         {
>
> //      Window.alert(arr[c2][0]+" <== ");
>
>        draw....
>        ....
>       c2++;
>
> }
>
> Now may the prob is in how i use the global variables arr and counter?
> i cant figure out why something like this is happening.
> Any idea ?
> Ty.
--~--~---------~--~----~------------~-------~--~----~
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