# How to refresh a widget

**URL:** <https://community.ofelia.com/t/how-to-refresh-a-widget/6623>\
**Category:** Q&A\
**Created:** [3 November 2015 22:18 UTC](https://community.ofelia.com/t/how-to-refresh-a-widget/6623 "2015-11-03T22:18:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbravo](https://avatars.discourse-cdn.com/v4/letter/d/9fc29f/32.png) [@dbravo](https://community.ofelia.com/u/dbravo)\
**Post date:** [3 November 2015 22:18 UTC](https://community.ofelia.com/t/how-to-refresh-a-widget/6623/1 "2015-11-03T22:18:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![johnny\_104](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@johnny\_104](https://community.ofelia.com/u/johnny_104)\
**Post date:** [4 November 2015 07:48 UTC](https://community.ofelia.com/t/how-to-refresh-a-widget/6623/2 "2015-11-04T07:48:23Z")

</div>

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);

---

<div class="post-metadata">

**Author:** ![dbravo](https://avatars.discourse-cdn.com/v4/letter/d/9fc29f/32.png) [@dbravo](https://community.ofelia.com/u/dbravo)\
**Post date:** [5 November 2015 13:56 UTC](https://community.ofelia.com/t/how-to-refresh-a-widget/6623/3 "2015-11-05T13:56:43Z")

</div>

Hi.

Thanks for your answer, I’ve tried it but the button widget does not have a GET action. ☹

---

<div class="post-metadata">

**Author:** ![johnny\_104](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@johnny\_104](https://community.ofelia.com/u/johnny_104)\
**Post date:** [6 November 2015 02:44 UTC](https://community.ofelia.com/t/how-to-refresh-a-widget/6623/4 "2015-11-06T02:44:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dbravo](https://avatars.discourse-cdn.com/v4/letter/d/9fc29f/32.png) [@dbravo](https://community.ofelia.com/u/dbravo)\
**Post date:** [9 November 2015 19:09 UTC](https://community.ofelia.com/t/how-to-refresh-a-widget/6623/5 "2015-11-09T19:09:31Z")

</div>

Hi.

Well, I’ve tried it, but the POST method to get data does not work with BDM. I always get this:

```
"code":405,"contactEmail":null,"description":"The method specified in the request is not allowed for the resource identified by the request URI","homeRef":"/","reasonPhrase":"Method Not Allowed","uri":"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.6"

```

Thanks for your answer.

---

<div class="post-metadata">

**Author:** ![johnny\_104](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@johnny\_104](https://community.ofelia.com/u/johnny_104)\
**Post date:** [11 November 2015 08:43 UTC](https://community.ofelia.com/t/how-to-refresh-a-widget/6623/6 "2015-11-11T08:43:00Z")

</div>

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.
