it is possible.
One way to achieve this is set a Timer in your form, using AJAX to call REST API to get BDM data instance of this case. Of course, you have to use a List to keep comments.
This approach is calling long-polling, which introduce additional cost on network and server, but this is compatible with all browsers.
We also can use another 2 new methods: Server-Event or WebSocket instead of long-polling.
Server-Event relies on a new JavaScript object “EventSource”. Refer to below sample, EventSource object will request to given URL for every 3 seconds and get response to update your form. However, we must set header “Cache-Control” to “no-cache” and content type with “text/event-stream” to given URL. So you might need add your own servlet into Bonita which implements backend logic using Bonita Java API.
<!doctype html>
Basic SSE Example
Page Loaded...
Server-Event approach is easy to implement, but its downside is IE does not support EventSource object, while other browsers including Edge support this object.
The 3rd option WebSocket will be a little bit complex. But it costs lest network traffic and lest server, because it only send messages whenever necessary. Usually I use Talend ESB which has Jetty component to implement this approach. A sample code of front-end will be similar to this:
<script type="text/javascript" src="http://localhost:8080/Origami/websocket/sockjs-0.3.min.js"></script>
<script>
var websocket;
if ('WebSocket' in window) {
websocket = new WebSocket("ws://localhost:8080/Origami/webSocketServer");
} else if ('MozWebSocket' in window) {
websocket = new MozWebSocket("ws://localhost:8080/Origami/webSocketServer");
} else {
websocket = new SockJS("http://localhost:8080/Origami/sockjs/webSocketServer");
}
websocket.onopen = function (evnt) {
};
websocket.onmessage = function (evnt) {
$("#msgcount").html("(<font color='red'>"+evnt.data+"</font>)")
};
websocket.onerror = function (evnt) {
};
websocket.onclose = function (evnt) {
}
</script>
WebSocket approach needs to use a second port,which could introduce some effort on firewall setup and others.
All 3 approaches above eventually call Bonita APIs, either REST API “http://…/API/bdm/businessDataReference/{caseId}/{businessDataName}” (here is the document: http://documentation.bonitasoft.com/bdm-api-0#businessdatareference) or Engine API “BusinessDataReference” (here is the document: http://documentation.bonitasoft.com/javadoc/api/7.2/index.html).
You could choose which is more suitable based on your circumstance.