Using a button to change a list

0
Hello.  I am trying to make an app that displays random recipes. For this I am using an API that I managed to set up like this: My problem is that now, using a list view I can consume the API but I want it to be displayed only after I press a button. Everytime the button is pressed, I want to make a new call to the API so that another random recipie will be displayed. I can't figure out how to set up that button so it refreshes the list and displays it only if it is pressed. I tried to make it happen using change list in the button microflow but I can't see the list.
asked
2 answers
0

Hi George,

What you can do is create a list view with a microflow as datasource. You can than put the microflow from your screenshot as the datasource microflow of your listview.

If you then refresh the page, the microflow will be triggered again. 

So what you can do to refresh the list on a button click, is open the page again. Another (more elegant) way to do it, is by refreshing the context object of your page. If you do a refresh in client on the context object in which the list view is situated, the microflow datasource of the listview will be retriggered and will show a new random item.

 

Another way (and in my opinion the most elegant way) would be to have one object as context object on your page, and a list of non-persistent objects connected to this context. On the button press, you can then re-fetch the objects from your API, and associate them to your context object and refresh them in your client. In the listview you will just show all objects that you have associated to the context object.

answered
0

Thank you very much!

 

answered