2

In GWT, I will use G chart to present data in the browser, in the gwt server side i will need one thread will generate random data, other threads will represent the data to the client(browser) in a timely manner say after every 2 sec(synchronously),How can i code in the server side ?? Any kind of help is appreciable.. Thanks in advance

1 Answers1

2

Writing code in the server side of GWT is really exactly the same as writing java code without GWT. In other words, once you get a hold of the data that the client sent inside your implementation of RemoteServiceServlet, then you are free to use whatever java code, libs, and/or frameworks to process that data.

From your description, it sounds like you need to kick off another thread to generate random data and then respond immediately to the client. You might want to read about creating new threads in java: http://download.oracle.com/javase/tutorial/essential/concurrency/.

There are several libraries that make it easier to run jobs. I'm familiar with quartz. You could use a scheduler like quartz to schedule a job that generates random data when the client requests? Or maybe it could just generate random data every so often?

From the client side, you'll probably want to poll every 2 seconds to check whether there is new data to display. Here'a another thread that gives some options for polling from gwt:

Client side Callback in GWT

  • Dave
Community
  • 1
  • 1
Upgradingdave
  • 12,916
  • 10
  • 62
  • 72
  • Hi Dave thanks for your direction,it is helpfull,I am using Timer as poll every 2 sec, but also can i use comet ? Now i am also able to communicate with server by using as you recommender RemoteServiceServlet (GWT-RPC technique).I will need to generate a hudge numbers of random data, for column 1(X-axis) it will be counter starts from 0 to infinity (very large number like 1,2,3,....333333345,4454545454545454) and in the column 2(Y axis in Graph) there will be random integer value from (-1000 to +1000).I need to create threads in the server side but as you said do quartz library can make it ?? – Asif Hossain Shantu Jan 13 '11 at 21:36