Filtering rows

You can filter the rows in a table by implementing the interface IlpFilter and setting it to the table.
To perform the filtering, you can use the method setFilter at two different levels:

At the adapter level

You have the choice to apply the filter to the table component or to the adapter, the result will be the same.
The following code shows how to create a filter displaying only IltNetworkElement instances with alarms.

How to set a filter to the table component

// Create a table component and set it to a data source
IlpTable tableComponent = new IlpTable();
IltDefaultDataSource dataSource = new IltDefaultDataSource();
// The second parameter specifies which kind of object contained 
// in the data source the table will show
tableComponent.setDataSource(dataSource, 
  IltNetworkElement.GetIlpClass());
IlpFilter alarmFilter = new IlpFilter() {
  public boolean accept(Object object) {
    IlpObject ilpObject = (IlpObject)object;
    Integer alarmCount = 
      (Integer)ilpObject.getAttributeValue(IltObject.AlarmCountAttribute);
    return (alarmCount.intValue() > 0);
   }
};
tableComponent.setFilter(alarmFilter);
The following example shows how to set a filter to an adapter.

How to set a filter to the adapter

adapter.setFilter(new IlpFilter() {
  public boolean accept(Object object) {
   IlpObject bo = (IlpObject)object;
   return bo.getAttributeValue(boolAtt).equals(Boolean.TRUE);
  }
});
The argument boolAtt passed to the method getAttributeValue is an instance of IlpAttribute that returns a Boolean value. Business objects will be transformed into representation objects only if this argument is true .

At the controller level.

Filtering takes places between the model and the view and is performed by the controller.

How to set a filter to the table controller

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.