| Business Objects and Data Sources > Data Sources > Adding Dynamic Business Objects > Adding Business Objects to the Data Source |
Adding Business Objects to the Data Source |
INDEX
PREVIOUS
NEXT
|
The default data source implementation, IltDefaultDataSource, provides methods to add and remove business objects. Once a business object is added into a data source that is connected to a graphic component, it can be automatically displayed by the graphic component.
If you want to add your business objects to the data source without having their graphic representation created, you need to use an IlpFilter and apply it to the IlpAbstractAdapter in charge. In this way, the objects are filtered out and not included in the graphic representation model. No graphic representation will be created at rendering time. You can, at a later stage, change the filter to make more objects visible as needed.
| Note |
The filter must be set on the IlpAbstractAdapter before the business objects are added to the data source.
|
Such filters allow the business objects to be managed by the data source and still not be represented graphically.
The following methods are available to add business objects to a data source:
void addObject (IlpObject obj): Adds a single object to the data source
void addObjects (List objs): Adds a collection of objects to the data source.
Whenever possible, large series of IlpObject instances should be added as collections instead of one by one. This is typically the case when you initialize the application.
For example, the code sample below:
for (...) {
parent = new IltNetworkElement("ROOT");
dataSource.addObject(parent);
for (...) {
child = new IltNetworkElement("NE");
dataSource.setParent(child, parent);
dataSource.addObject(child);
}
}
Could be improved to:
List objects = new ArrayList();
for (...) {
parent = new IltNetworkElement("ROOT");
objects.add(parent);
for (...) {
child = new IltNetworkElement("NE");
dataSource.setParent(child, parent);
objects.add(child);
}
}
dataSource.addObjects(objects);
When the business objects are no longer needed by the application, they can be removed from the data source using one of the following methods:
IlpObject removeObject(Object idOrIlpObject, boolean childrenToo): Removes the required object from the data source. The argument "childrenToo" is used to indicate if the whole object subtree should be removed from the data source at the same time.
List removeObjects(List idsOrIlpObjects, boolean childrenToo): Removes a collection of objects from the data source.
void clear(): Removes all business objects from the data source.
Whenever possible, large series of IlpObject instances should be removed as collections instead of removing the objects one by one.
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. All rights reserved. Legal terms. | PREVIOUS NEXT |