3

I am using GWT and i am making RPC calls to get some data from database. I use this data to draw charts with Google Charts API. The problem is that GWT RPC call is async and my chart is always using data from the last call, not the current one.(i populate int array in onSuccess function)). How should i wait some time to make sure that RPC completes and writes my array and then draw my chart, since there is no Thread.sleep() function?

DixieFlatline
  • 7,895
  • 24
  • 95
  • 147
  • One idea is you can add the charts to panel after you process your RPC response (Converting into int[]). Your question is not clear!! Can you please elaborate your question? – DonX Sep 08 '10 at 11:44

3 Answers3

6

You should draw chart in onSuccess(). Why aren't you?

amorfis
  • 15,390
  • 15
  • 77
  • 125
  • I did as you suggested, but it takes about 20s to draw the chart and the button that i use to start drawing keeps flashing, evethough it should be disabled until the chart is drawn. Just for test, i made the button that fetches the same data via RPC as the data that is needed for the chart, i get that data in a second or less?! – DixieFlatline Sep 08 '10 at 14:06
  • Solved, tnx for solving this little riddle. – DixieFlatline Sep 08 '10 at 14:12
1

Another way is to use event bus and custom event to draw charts based on retrieved data. When rpc call returns with success you create this event and fire it. Appropriate controller should subscribe to the event and draw chart upon receiving it. See this on how to implement it.

Community
  • 1
  • 1
topchef
  • 19,091
  • 9
  • 63
  • 102
0

GWT make RPC blocking

Community
  • 1
  • 1
Gursel Koca
  • 20,940
  • 2
  • 24
  • 34