14 - Implement Spinner for Product Details Page
Set up and use a spinner control to hide UI until all data is available to display, as part of the SAP CodeJam.
Overview
You will learn
- How to set up and use a spinner control
- How to delay displaying data until it is retrieved
Prerequisites
Prerequisites
- You have completed the previous tutorial for the SAP Build CodeJam, Enable App to Filter Products.
Steps
Go to the Product Details page.
Toggle to Variables.
Create a new page variable, and set its properties to the following:
Name Type Variable name showSpinnerVariable value type True/false Initial value True 
Page Variables on Product Details
Toggle back to View
Drag the spinner control from the Core components tab – currently the very first component – and place it on the page.

Placing the Spinner It will be easier to place it by dragging and dropping on the UI canvas
With the spinner selected, go to the Advanced Properties > Visible property.
Click the binding icon, and set the binding to Data and Variables > Page Variable > showSpinner.
This is the variable you created in the previous step.

Visible Property under Advanced
In the Tree View, select the Product Details container.
Under Advanced Properties, click on the binding icon for the Visible property.

Visible Property under Advanced Select Formula and set the formula to the following:
JavaScript!pageVars.showSpinnerBefore saving the formula, set the Optional preview data to True.

Visible Property under Advanced Save the formula, and then click Save (upper right).
This will set it to the opposite of the spinner. So when the spinner is visible, the product details UI is not, and vice versa.
What does the formula do?
The formula will show the page components only when the spinner is hidden. So initially, the spinner is shown and the page is hidden; when the data is all retrieved, the spinner is hidden and the page components are shown.
We set the Optional preview value because by default the Visible property is false and this will hide all the page components while we are designing them. So in order to see them while we work on building the page, we set the preview to True.
Toggle to Variables.
Select Data Variables, then select Products1.
Open the logic canvas.
In the logic canvas, add a Set page variable flow function to the end of the flow.
Set Variable Name to showSpinner.
Set Assigned value to False.

Visible Property under Advanced Click Save (upper right).
Launch the app.
Select a product, which will take you to the Product Details page.
Select product On the Product Details page, you will first see the spinner and nothing else on the page.
Spinner displayed When the data is returned, the spinner will disappear and the product details will be displayed
UI displayed
The way we just implemented the spinner, with a dedicated spinner UI component, lets us create a spinner for just a part of the screen.
But if we just want to hide the entire screen until the data is ready, there are dedicated spinner flow controls that make this easy.
Go back to the UI Canvas to the Product Details page.
Remove the spinner component.

Remove spinner In the tree view, select the Product Details container, and set the visibility back to True.

Back to true Click on Variables > Data Variables, select Products1, and open the logic pane.
Remove the Set page variable flow function.

Remove flow function Add a Show spinner flow function at the start of the logic, and then a Hide spinner at the end of the logic. Arrange the flow functions like this:

Spinner Click Save (upper right).
Relaunch the application.
Select a product. Now, on the Product Details page, the entire page – including the navigation bar at the top – is hidden with a large spinner in the center of the page until all the data is retrieved.

Big spinner
Resources
Discussion
Share feedback on this tutorial or join the conversation in SAP Community.