Custom filter components

Creating a custom filter component

The framework provides numerous filter components, that can be used as individual, single components or together with the ListGrid component. However, you may need to create a custom filter component. For this reason, there is an ancestor class in the framework. Every filter component must extend from this class. Custom components that extend from this class can be used together with the ListGrid component, and every basic filter functionality can be accessed as well.

The custom filter component must extend from the BaseFilter class. This is an abstract class, that requires the extended class(es) to implement the following methods:

  • setDataDescriptor : You must implement the processing of the DataDescriptor in this method. If the filter component has no DataDescriptor assigned to it, the method must still be used, but in this case it only has to implement the triggering of an UnsupportedOperationException
  • setEditorSate : The state of the filter editor can be set here. This method is called automatically, when the state of the filter component can change.
  • reset : The filter component can be reset with this method. This method is called automatically, when the filter must be reset to its default state.
  • setCriteria : The criteria that will be used by the filter component can be set here.
  • getCriteria : This method must receive and return the Criteria object used in the filter component. The method call automatically takes place if the Criteria is needed for data retrieval (query).


In the following example, you will create your own filter component, that can be displayed together with the ListGrid component on a page. If the user filters with the component, that filter will be applied to the data displayed in the ListGrid. The filter component itself will be rather simple, it will be a Combobox, that will allow the user to select a state, which will be applied automatically. There will be a checkbox on the filter component as well, that will be ticked in by default. If the checkbox is ticked in, only the valid records will appear in the list, otherwise every record will be listed. This filter component will check if the correct records are in the specified DataDescriptor. If the DataDescriptor has no status column, the filter component’s combobox will not be functional. If it has no valid column, the checkbox will not be functional.

The filter component source code:

This component is ready to be used as a custom standalone component, or with a ListGrid component.

Displaying the filter component and a list on a page. If the user modifies the filter component, the list contents will automatically reflect the changes caused by the filter.