Custom Selection part 2: Build a Reusable Selection Component
Previous step: Cached Selection.
In this version we take the solution one step ahead, and allow for the cached selection to be used from different models. The application looks similar:
1. We start be creating a separate component for the selection. Create a new model of type Composite View:
2. Add the required Data Service. Connect a Data In element to its input port, and a Data Share and Table to the output:
3. Add a Data Share and name it variables. Add a field with default value false to tell us whether the component was activated already:
4. Set the Mapping to the Data Share so the value is changed when the component was activated:
5. Add a link between the input port and the banks Data Share. Set its guard condition in the Configure Panel to: =valiables@initialized==true.
6. For the link between the input port and the Data Service define: =valiables@initialized==false. This way the service is executed only at the first use of the component.
7. Add a Data Share element and name it choice. Set its scope to public in the Configure Panel, and add a field for the selected bank:
8. Set the mapping:
9. Now we move to creating the model that uses this component. We could use the model from the previous solution:
10. Delete the Table View, the Start Point and the Data Service.
11. Go to the Search panel and search for the bank selection component we created (You could use the advanced Search to specify the specific DC):
12. Drag the banks component to the Popup and connect the Form View to its in1 input port.
13. Set the choose_bank action as the Event to activate the component:
14. Choose the Popup and go to the Layout Board. Define the Assign action on the OK button to take the value from the port choice of the nested component (public Data Share in the component):
Next step (coming soon): Allow for consumers of the selection to pass different inputs (and thus get different results).