Object BOM Native Type and ScriptUtil.setObject()
The default assignment of a Business Object (for example, a BOM Class instance) to an Object BOM Native Type attribute (imported xsd:any) looks like this [from the previous example]:
If the BOM was created in TIBCO Business Studio, then there is only one element for each type, so the above example will always produce the desired result. However, if the BOM was created by importing an XSD Schema and the simple assignment interface is used, then BDS will automatically select the best available element in which to store the complex object.
For situations where you wish to specify which element the complex data is stored as, a utility method can be used, as in the following example:
ScriptUtil.setObject(outputField1.bomObject1, bomField3, "com.example.bomobjectexample.Class3Element"); |
For the above example, to find the parameters that can be used in this case you need to find the name of the element associated with the class (type). Select the class in the BOM editor, and look at the advanced properties sheet:
At the bottom of the property sheet, the XsdTopLevelElement property is listed. In the screenshot above, there are two elements: Class3Element and Class3ElementB. This ScriptUtil function allows the script writer to define which element the xsd:any should be associated with.
The element name is combined with the BOM namespace to make up the third parameter to the ScriptUtil.setObject() method. For this BOM example, the namespace can be found in the Name field of the BOM properties sheet:
Concatenating the two parts results in the following ScriptUtil.setObject() line: