Runtime components : Core components : Data elements : Tasks : Using data elements
  
Using data elements
To use data elements, do the following:
1 During the analysis and design of the application, identify the data it needs.
2 For each type of data, check whether the data definition file or the processor self-defined file already contains a definition that you can use.
3 Create data structures for the application.
Use references for data elements that have already been defined elsewhere or create data element definitions for the ones that have not. If the data element is a keyed collection and the application needs to add elements to it during runtime, set its dynamic attribute to true
4 If the data is to appear in a context, include a reference to it in the context keyed collection definition.
5 Instantiate the data elements needed by the application.
The toolkit automatically instantiates data elements belonging to a context when it instantiates the context. You can instantiate other data elements at any time by using the DataElement readObject(String) method.
6 To obtain the value of a data field, use the getValue() method without parameters. To obtain the value of a data field inside a collection, use the getValueAt(String key) method in which you pass a simple or composite key.
7 To set the value of a data field, use the setValue(Object) method.
If the data field is to be added to a dynamic keyed collection, use the setValueAt(String, Object) method, where String can be a simple or a composite key, and Object is the value of the data field.
Note If the collection has its dynamic attribute set to false and you pass in a data element name that does not exist in the collection, an exception occurs.
For more information on using data elements, see the Javadoc for DataElement, DataField, DataCollection, KeyedCollection, and IndexedCollection.
See also
Tasks