Introduction
This example takes the very simple flow element described in the simple flow element example, and adds a JavaScript property to use client side evidence.
Instead of using evidence which is already available, as the simple flow element example did, this example will send JavaScript to the a client to get the evidence.
Download Example
The source code used in this example is available here:
Dependencies
The flow element will need a dependency on the Pipeline core package
Data
The element data being added to the flow data by this flow element is a star sign. So this should have its own 'getter' in its element data. The additional property containing the JavaScript to get the date of birth is also added using the appropriate type.
JavaScript
The client-side JavaScript for this example will be fairly simple. It will create a popup asking the user to enter their date of birth. It will then store the date of birth in a cookie named 'date-of-birth' and reload the page with the new cookie present.
The JavaScript to do this looks like:
Flow Element
Now the actual flow element needs to be implemented. For this, the flow element's base class can be used which deals with most of the logic. The element properties, evidence keys and the processing are all that need implementing.
Builder
Now the flow element needs one final thing, an element builder to construct it. This only needs to provide the flow element with a logger and an element data factory - as this example has no extra configuration options.
Usage
As this example gathers its evidence using client-side JavaScript, it will need to be run in a web environment. Using a web integration will mean that the flow element can be added, and the client-side JavaScript automatically run.
Next Steps
The example for Custom On-premise Engine shows how you can extend the functionality of this flow element to use a data file rather than hard coded values.