IlpTableController controller = table.getController();
controller.setFilter(new IlpFilter() {
public boolean accept(Object object) {
IlpObject bo = (IlpObject)object;
return bo.getAttributeValue(boolAtt).equals(Boolean.TRUE);
}
});
The
setFilter method at the adapter level may
seem redundant with the
setFilter
method at the controller level; however, the advantages and
drawbacks are not the same. Modifying the filter associated
with an adapter to which a number of representation objects
have already been added causes a large number of objects to be
created or destroyed. Whereas changing a filter set to the
controller only alters intermediate data, without leading to
object creation or destruction. Setting a filter to an adapter
significantly improves the performance, since it avoids
creating a great number of unused representation objects, and
saves storage space in the memory of the model.
The most likely scenario for using the
setFilter method at two different levels
is the following: The
setFilter
method at the adapter level can be considered the first step in
the filtering process in the sense that it reduces the number
of objects of the accepted class that will be created and
displayed. The next step consists in setting a filter at the
controller level to further reduce the number of objects that
will be actually displayed in the table component.