In most cases, you use the database, association or XPath data sources to fill a data widget. However, sometimes the target objects need to adhere to very specific criteria, or different objects are shown under different circumstances that cannot be handled by an XPath. In these situations a nanoflow data source may be required. For more information on nanoflows and their advantages, see Nanoflows.
When a data widget with a nanoflow data source is displayed in the browser or refreshed, it runs the designated nanoflow and displays the return value. The manner in which the objects are acquired in the nanoflow is entirely up to you, which allows for unlimited control over what objects to return.
A nanoflow data source ignores all context. It performs actions described in the nanoflow, nothing else. For example, nested data containers with a nanoflow data source will not automatically create or invoke associations to the encasing data widget.
2 Nanoflow Data Source Example
For example, you have a list that needs to display a list of potential orders based on the order type:
If the OrderType of the Order entity is set to Cars, then the data grid should display all Products for which the Boolean Motorized is set to true. If the OrderType is Bicycles only objects for which Motorized is set to false need be shown. If OrderType is empty the data grid should remain empty.
Because of the mismatch in attribute types this cannot be constrained by XPath and a nanoflow data source is required.
The nanoflow for the use-case should look like this:
This nanoflow does the following:
It passes the Order of the enclosing data view as a parameter.
It then splits on the OrderType attribute and retrieves a different set of products for each enumeration value.
The nanoflow returns a list of products and each end event is configured to return a list.
The empty path also requires a value, where
emptyis also a value.
Defines the nanoflow used to populate the widget. This nanoflow will be run whenever the widget is loaded into the browser or refreshed. The nanoflow must have a return value of either an object or a list of objects, depending on the widget being used.