6.5.2 Sharing Data

As an example, consider an application that needs to share a shopping cart. The shopping cart may be represented by a list and may contain a product identifier, product name, and quantity. Consider a WEBEVENT application where a customer adds a number of products to a shopping cart list. In your WEBEVENT code, you can assign a unique identifier to STDANCHOR and then insert entries in the shopping cart list into a database table with STDANCHOR as a key. Add STDANCHOR to the DISPLAY command to ensure that its value is available in the form as a hidden field.

When a WEBEVENT form is shown in the browser, it will also contain the STDANCHOR unique identifier. You can then navigate to a WAM using the HandleWAMEvent() JavaScript function as described in 6. WAM and WEBEVENT Interoperability.

HandleWAMEvent() automatically looks for the STDANCHOR field in the form and submits its value as well.

On the WAM side, the STDANCHOR field needs to be placed on the WEB_MAP to ensure it is mapped into the WebRoutine. When the target WebRoutine is executed, it will receive the STDANCHOR identifier value and any other field values passed via HandleWAMEvent() and mapped into the WebRoutine on the WEB_MAP. In the WebRoutine, the shopping cart list can then be retrieved from the database table using the STDANCHOR key. The values can then be placed into a WAM list that belongs to WAM Session state and the data keyed by STDANCHOR deleted from the database. Alternatively, a special cleanup job can be scheduled to run to clean up stale data from the database.

To pass data from a WAM to a WEBEVENT, the steps above can be performed in reverse order. The HandleWebEvent() JavaScript function automatically looks for the STDANCHOR field on the WAM form and submits it with the rest of submitted data.