Hi,
In our vaadin application we are using javascript.js (by extending AbstractJavaScriptComponent)script to render chart visualization. For on of the requirement we need charts data to be refreshed on an regular interval. To achieve it I am writing a function which will prepare a http request and post it. In normal servlet it could be done easily by overriding doGet/Post method and invoke servlet from javascript being within same application. The issue I am facing here is Vaadin is not a simple servlet than it has wrapper around it. And I am having difficulty to write implementation for doGet and doPost to read the request parameter and call to the service method. I am not getting hold on those methods.
As i come to know it possible that we can call javascript methods form vaadin, but that would need a executable threads to run in an interval to push the updated data but i dont want the javscript state to be changed instead the chart should show updated data once it got navigated back, since our application already dealing with many other thread it might introduce performance issue.
Form my script I am writing request like below.
var url = "/monitorMap/?fetch=masterData";
http.open("GET",url);
http.send();
http.onreadystatechange=(e) => {
try{
var data = JSON.parse(http.responseText);
}catch(e){
console.log("Exception occured while sending/reading request " +e);
}
}
then I am having javascript interval which will invoke the method in regular interval.
window.setInterval(pullMasterData(), 20000);
I am trying to know whether below could be possible with vaadin or not.
- ability to receive request parameter sent by javascript request.
- perform checks and call service methods.
- send back the response to the caller.
thanks