Complex model objects are those objects in a model that
map to more than a single value. Instead, these objects map to an
entire object, or a collection of objects, in a data set using an
internal multi-column table of values.
You can use complex model objects to control data retrieval from
a given source using values from one internal column to select the
row of data to retrieve. For example, if the complex model object
is a collection of employees, you can display a list of first names
to users and then display the entire record for an employee based
on the selection.
Alternatively, you could use the single complex model object
as a data input to a Guide extension, such as a custom control.
In this way, you can provide a much richer set of data to the custom
control to create additional functionality for the Guides user.
Walkthrough creating a complex model object
This walkthrough describes how to create a complex data
object using a model. Before you begin, ensure that you complete
the following tasks:
Note:
This walkthrough uses the following model definition
and sample XML data definition:
Sample model definition
<model xmlns="http://ns.adobe.com/Fiber/1.0">
<entity name="Entity" persistent="true">
<annotation name="VisualModeler">
<item name="x">46</item>
<item name="y">43</item>
<item name="width">115</item>
<item name="height">78</item>
</annotation>
<id name="ID" type="integer" generated="false"/>
<property name="employees" type="Employee[]"/>
<property name="employee" type="Employee"/>
</entity>
<entity name="Employee">
<annotation name="VisualModeler">
<item name="x">247</item>
<item name="y">93</item>
<item name="width">115</item>
<item name="height">94</item>
</annotation>
<property name="firstName" type="string"/>
<property name="lastName" type="string"/>
<property name="address" type="string"/>
<property name="employeeHistory" type="EmployeeHistory[]"/>
</entity>
<entity name="EmployeeHistory">
<annotation name="VisualModeler">
<item name="x">434</item>
<item name="y">102</item>
<item name="width">115</item>
<item name="height">62</item>
</annotation>
<property name="employer" type="string"/>
<property name="jobDescription" type="string"/>
</entity>
</model>
Sample XML data
<employeeinfo>
<Entity>
<ID>0</ID>
<employees>
<firstName>Tony</firstName>
<lastName>Blue</lastName>
<address>1 ABC Street</address>
<employeeHistory>
<employer>123 Contracting</employer>
<jobDescription>Senior Software Developer</jobDescription>
</employeeHistory>
<employeeHistory>
<employer>123 Contracting</employer>
<jobDescription>Junior Software Developer</jobDescription>
</employeeHistory>
</employees>
<employees>
<firstName>Alex</firstName>
<lastName>Pink</lastName>
<address>10 XYZ Avenue</address>
<employeeHistory>
<employer>Bobby's Road House</employer>
<jobDescription>Cook</jobDescription>
</employeeHistory>
</employees>
<employees>
<firstName>Chris</firstName>
<lastName>Black</lastName>
<address>33-C Alphabet Lane</address>
<employeeHistory>
<employer>Big Bank Incorporated</employer>
<jobDescription>Branch Manager</jobDescription>
</employeeHistory>
<employeeHistory>
<employer>Little Bank Corporation</employer>
<jobDescription>Customer Service</jobDescription>
</employeeHistory>
<employeeHistory>
<employer>Small Town Co-operative</employer>
<jobDescription>Custodian</jobDescription>
</employeeHistory>
</employees>
<employee>
<firstName />
<lastName />
<address />
</employee>
</Entity>
</employeeinfo>
Create a complex object
-
In the Data Model view, drag
the employee entity into the Guide.
-
In the Data Model view, expand the employee entity. Drag
the firstName, lastName, and address objects into the Guide.
-
In the Guide Tree view, select the Employee object.
-
In the Guide properties view, set the List source property
to Entity.employees.
-
In the Guide properties view, set the List text property
to the model property to display in the drop-down list at run time.
For example, select firstName.
-
In the Guide Tree view, select the root node of the Guide.
In the Guide Properties view, specify the location of the sample
data file to use in the Sample data property.
-
Save the Guide, and the click Preview in the editor.
When
the Guide renders in the browser, click the Employee drop-down list
and select a name. Notice that the First Name, Last Name, and Address
fields update with the corresponding values from the sample data
file.
If you want to display a customized value in the drop-down list, for example lastname, firstname, create a derived property in the model. Once ready, set the value of the List text property for the drop-down list equal to the name of the derived property.
|
|
|