| Graphic Components > Tree Component > Tree Component Services > Filling the Tree with Business Objects |
Filling the Tree with Business Objects |
INDEX
PREVIOUS
NEXT
|
The tree can be filled with business objects through an IltDefaultDataSource, as illustrated by the following code.
// Create a tree component and connect it to a data source
IlpTree treeComponent = new IlpTree();
IltDefaultDataSource dataSource = new IltDefaultDataSource();
// The second parameter specifies which kind of object contained
// in the data source the tree will show
treeComponent.setDataSource(dataSource, IltNetworkElement.GetIlpClass());
// Create a business object and insert it in the data source
IltObjectState os = new IltBellcoreObjectState();
os.set(IltBellcore.State.EnabledActive);
IltNetworkElement london =
new IltNetworkElement("Fax", IltNetworkElement.Type.Fax, os);
dataSource.addObject(london);
Note that a data source can also load an XML file containing business objects, as shown in Creating a Tree Component: a Sample.
You can also use project files to easily create and load data source business objects into your tree component, as illustrated below:
You can create the following project file to indicate the type of data source to be used and the XML file that contains the data source information:
<?xml version="1.0"?> <tgo xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation = "ilog/cpl/schema/project.xsd"> <datasource javaClass="ilog.tgo.datasource.IltDefaultDataSource" fileName="network.xml"/> </tgo>
Once the project file is specified, you can load it in the component using method IlpTree.setProject(URL projectURL) or IlpTree.setProject(IlpProject project). See Loading a Project File for details.
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. All rights reserved. Legal terms. | PREVIOUS NEXT |