Hi,
The requirement of my application is to continously poll the server till the response is not received.


Controller class code:

private String getChartData() throws InterruptedException {
String chartData = "{'chart' : {'bgcolor' : 'FFFFFF,CCCCCC','showpercentagevalues' : '1','plotbordercolor' : 'FFFFFF','numberprefix' : '$','issmartlineslanted' : '0','showvalues' : '0','showlabels' : '0','showlegend' : '1'},'data' : [ {'value' : '212000','color' : '99CC00','alpha' : '60'}, {'value' : '96800','color' : '333333','alpha' : '60'}, {'value' : '26400','color' : '99CC00','alpha' : '30'}, {'value' : '29300','color' : '333333','alpha' : '30'} ]}";
Thread.sleep(20000);
return chartData;
}



Action class code:

@DirectPollMethod(event = "poll")
public String handleMessagePoll(Map<String,String> parameters) {
assert parameters != null;
Date now = new Date();
SimpleDateFormat formatter = new SimpleDateFormat(
"dd/MM/yyyy 'at' hh:mm: ss");
System.out.println("Successfully polled at: " + formatter.format(now));
return "Successfully polled at: " + formatter.format(now);
}



JS code:

var pollingProvider = Ext.Direct.addProvider({
type: 'polling',
interval: 5000,
url: Ext.app.POLLING_URLS.poll,
id : 'poll1',
listeners: {
data: function(provider, event) {
Ext.log( 'poll');
updateMain('<i>' + event.data + '</i>');
getChartData(); // Receives json object from controller class to plot a chart
pollingProvider.disconnect();
}
}
});
pollingProvider.connect();



The problem I'm facing is the polling code (with the chart code) is getting sleep for 20 secs.
Instead I want the polling to be displayed till the chart data is received by the client. And as soon as chart data is received, close the polling also.

Please help me. I am not getting any clue to intergrate the server functionality with the polling technique. I am using Ext.Direct with DJN.

Thanks,
Shweta Sharma