Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
PagedTable filtering problem
Hai friends,
I am using a PagedTable in my application. I tried to add a filter to the table it throws an exception
java.lang.ClassCastException: com.jensjansson.pagedtable.PagedTableContainer cannot be cast to com.vaadin.data.Container$Filterable
This is my code
BeanItemContainer <Institution> institution = new BeanItemContainer<Institution>(Institution.class);
institution.addAll(institutionsList);
PagedTable institutionTable=new PagedTable("");
institutionTable.setContainerDataSource(institution);
TextField search=new TextField();
search.addStyleName("search small");
search.setInputPrompt("institution name");
search.addListener(new TextChangeListener() {
Filter filter = null;
public void textChange(TextChangeEvent event) {
Filterable f = (Filterable)
institutionTable.getContainerDataSource();
// Remove old filter
if (filter != null)
f.removeContainerFilter(filter);
// Set new filter for the "Name" column
filter =new Like("instName", event.getText() + "%", false);
f.addContainerFilter(filter);
}
});
please help me how to add a filter to the PagedTable.
Thanks in advance...........
Filterable f = (Filterable)
institutionTable.getContainerDataSource();...
at this line iam getting the error....
The problem here is that PagedTableContainer does not implement the interface Container.Filterable, but you are trying to cast it anyway. That's why the exception is thrown.
If you would like to use filters with a PagedTable, you should extend the PagedTableContainer and implement Container.Filterable
Please have a look at the FilteringTable add-on. I recently added support for filtered & paged table. If you don't want to use the filtering features you can at least see/copy the changes you need to make to the PagedTable to get it working with a filterable container.
filter table will give the pagination functionality...?
Yes, it will, since the quite recent version 0.8.0. Look at the PagedFilteringTable class, it should do what you need.