Show TOC

Storing Data in a Data StoreLocate this document in the navigation structure

Context

A Data Store is a central data container in which you temporarily store data for later use. The data is stored in memory, and is available at runtime as long as the modeled application is open. When the modeled application is closed, the data store is emptied.

Each model uses a single Data Store . To make it easier to connect elements to the Data Store , you can add multiple Data Store elements to the Design board. However, these multiple Data Store elements all represent the same Data Store (data stored in one element is visible in the other elements).

The connecting lines to the input port of the Data Store are of data mapping type. The values in the Data Store are accessed using expressions.

Procedure


  1. In your model, drag a Data Store connector from the Compose task panel to the Design board.

  2. Drag from the out port of the UI element whose data is to be stored in the Data Store to the port of the Data Store element.

  3. Define a virtual field in which to store the data:

    1. Right-click the Data Store element and from the context menu, choose Define Data .

    2. Define a virtual field for the Data Store by clicking the Add Field button and choosing the type of data that you want to store. Add more fields as required.

    3. The field is added with a default name. If you want to give it a meaningful name, click the Rename Field button and enter a new name.

    4. To define a default value for each field, enter it in the Default Value column.

  4. Define the event used to transfer data to the Data Store :

    1. Right-click the connecting line to the Data Store , and from the context menu choose Rename .

    2. Name the event with the same name as the action that adds items to the Data Store (defined in step 6), for example: Add_Item .

  5. Map values from the UI element fields to the Data Store fields:

    1. Right-click the connecting line between the elements, and from the context menu choose Map Data .

    2. In the Assigned Value column, choose a UI element field, enter a field name, or define a dynamic expression to specify from where to take the value that is placed in the Data Store .

  6. On the Layout board, add a toolbar button for transferring items to the Data Store :

    1. Select the UI component that contains the values to send to the Data Store and in the Configure task panel, select Show Toolbar .

    2. From the Compose task panel, drag a Button control to the toolbar, and assign it a custom action with the same name as the event you defined in step 4, for example, Add_Item . For more information, see Configuring Actions .

  7. On the Design board, drag a Form View icon from the Compose task panel to create a stand-alone form that displays the Data Store values at runtime in the component.

  8. Define a virtual field to display the Data Store values:

    1. Right-click the Form View element and from the context menu choose Define Data .

    2. Define a virtual field for the form by clicking the Add Field button and choosing the type of field.

    3. The field is added with a default name. Give the field a meaningful name (the name is displayed as the control label in the form), by clicking the Rename Field button and entering a new name.

    4. In the Control column, choose the type of control that you want to add to the form for the field.

    5. In the Default Value column, click the Define Expression button to open the Dynamic Expression Editor dialog box. In the list of functions in the right pane, expand the Data Fields group, then expand the store group, and double-click the name of the field in the Data Store . This is the field whose values will be transferred from the Data Store to the form.

    6. Click OK to close the Dynamic Expression Editor dialog box.

    7. Click Close in the Define Data dialog box.

Results

At runtime, when the user selects an item and clicks Add Item , the item name is displayed in the field in the stand-alone form. When additional items are selected, they are concatenated in this field.