Using bean data elements

About this task
To use bean data elements, do the following:
  1. During the analysis and design of the application, identify the bean 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 Java™ Beans as data model for the application. Use references for bean data elements that have already been defined elsewhere, or create data element definitions for the ones that have not.
  4. If the bean data is to appear in a context, include a reference to it in the context beancollection definition.
    <context id="customerCtx" type="test"><refKColl refId="customerBean"/></context>
  5. Instantiate the bean data elements needed by the application. The toolkit automatically instantiates bean data elements referenced by a context when it instantiates the context. You can instantiate other bean data elements at any time by using the BeanCollection bColl=DataElement readObject(String) method. You can also create a BeanCollection instance by API such as: BeanCollection bColl=new BeanCollection(new Customer()).
  6. To obtain the value of a bean collection, use getValueAt(String key) method in which you pass a simple or composite key. Do not use the dot character (.) in the key parameter in getValueAt(String key) method, because the dot character is the logic separation char. Compared to Keyed Collection, bean collection's key parameter cannot contain the asterisk character (*). If an asterisk character is used as key to get value, an exception occurs.
  7. To set the value of a bean collection, use the setValueAt(String, Object) method, where String can be a simple or a composite key. Note that if you pass in a data element name that does not exist in the collection, an exception occurs.
What to do next
For more information about how to use bean data element, see the Javadoc for DataElement, DataField, DataCollection, KeyedCollection and BeanCollection.