How to refresh a widget
Hi,
I have a process built in Bonita 7.1.2. and I've made a summary page for all the active cases. I use some widgets as a Data Table, texts, etc.
My question is, how can I put a button or something that refreshes the data on the summary page? I don't want implement a method that refreshes the window, I only want to refresh the Data Table.
Thanks in advance.
David.
I think you can simply add the button and set the followings:
action = POST (corrected)
url = the URL to your case list (should the the url where you load your data table)
Data to Send = empty variable
Successful value = the bind variable of your data table
If you need auto refresh, you may need to create custom widget which uses a setTimeout script to call http request periodically.
Something like (not tested, please do the debug yourself :):
function doPeriodicRequest(httpAction, url){
$http({method:httpAction,url:url})
.success(function (response){
$scope.properties.dataOnSuccess = response;
}).error(function (response){
$scope.properties.dataOnFailed = response;
});
setTimeout(doPeriodicRequest(httpAction, url),$scope.properties.period);
}
setTimeout( doPeriodicRequest($scope.properties.action, $scope.properties.url), $scope.properties.period);
Comments
Hi.
Thanks for your answer, I've tried it but the button widget does not have a GET action. :(
sorry, I was wrong about that, POST should also work, just return an empty variable in the data sent on click. I used this trick to load dynamic table on click.
Hi.
Well, I've tried it, but the POST method to get data does not work with BDM. I always get this:
Thanks for your answer.
Sorry, I got the same problem switching to POST. I have created a custom widget to handle the refresh.
Basically you can copy the pbButton.js logic from workspace/default/web_widgets/pbButton/ folder. Add one more option to the action list for GET. Then you can refresh as you press the button.
As for auto-refresh, I found setTimeout() may cause dead loop in Angular. Use $interval to callback the doRequestDelayed function to reload the content.