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.
FilteringTable add-on
Hi!
I just released a new add-on, FilteringTable. It was supposed to be named FilterTable but someone had already taken that name even though the add-on is no longer available.
Anyway, FilteringTable is basically a customized Table which just adds optional filtering components between the header and body of the Table. The components and filters are generated automatically based on the property types in the container. You can also provide your own filter implementations for any property by implementing the FIlterGenerator interface.
The filter components can not currently be generated by the developer, instead a set of components is provided: enum and boolean properties will get a ComboBox, Date properties get a custom date interval selector and all other types get a simple TextField. For example of implementing Integers with the TextField, see the code examples in the add-on page in directory.
A simple demo application is available here.
You can also provide some customizations to the automatically generated filtering components, as you can see from the demo application. For example you can set the item captions and icons in the ComboBoxes and various captions in the date interval selector.
I welcome any further development ideas and bug reports, so please post them directly to this thread!
Currently known issues:
- Focusing when keyboard-navigating between filter fields does not work correctly
- FilterDecorator must be set to the table before the container is set
-Tepi
Hi,
Your plugin suits exactly a use case I would like to implement this week. But I am using a tree table (and not a table). I guess FilterTable extends Table.
Any idea how hard it would be to suit this add-on to tree table as well? Also, I am happy to dig in the code and implement that myself. Is the code available somewhere?
Thanks,
S.
Hi,
The widget seams great, however I am having trouble compiling it. I get the following error on compilation:
[ERROR] 28-Feb-2012 16:28:27 com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getAvailableWidgetSets
[ERROR] INFO: Widgetsets found from classpath:
[ERROR] com.vaadin.terminal.gwt.DefaultWidgetSet in jar:file:C:/dev/mvnrepo/com/vaadin/vaadin/6.7.5/vaadin-6.7.5.j
[ERROR] com.abc.widgetset.Vaadin_pushWidgetset in file://C/dev/workspaces/WS_AdminTo
main/resources
[ERROR] org.vaadin.artur.icepush.IcepushaddonWidgetset in jar:file:C:/dev/mvnrepo/org/vaadin/addons/icepush/0.2.0/
[ERROR] org.tepi.filtertable.gwt.FilterTableWidgetset in jar:file:C:/dev/mvnrepo/org/vaadin/addons/filteringtable/
[ERROR]
[ERROR] 28-Feb-2012 16:28:27 com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getAvailableWidgetSets
[ERROR] INFO: Search took 0ms
[INFO] [resources:testResources {execution: default-testResources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\dev\workspaces\WS_AdminTool\AdminTool\modules\admin-web\src\test\resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] No sources to compile
[INFO] [surefire:test {execution: default-test}]
[INFO] No tests to run.
[INFO] [gwt:compile {execution: default}]
[INFO] auto discovered modules [com.abc.widgetset.Vaadin_pushWidgetset]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] GWT Module org.vaadin.hene.popupbutton.widgetset.PopupbuttonWidgetset not found in project sources or resources.
If I remove the dependency to the widget from my pom file and leave only the Icepush addon dependency my project compiles. So Im not sure what the problem here is. Any idea?
Thanks in advance.
Great widget, *should be standard feature of Table and TreeTable* !
But a few notes:
- the very first feedback when I showed this to a user was "it should be possible to filter as soon as I stop typing"
- so I went ahead and extracted the source from the jar
- and I created two maven projects, one for the jar, and one for the demo.
- and I made the requested improvement
Please find enclosed a zip file with the two Maven projects.
In my variation, FilterDecorator class now has one more method isTextFilterImmediate(Object propertyId). If this method returns true, then the TextField is created with a TextChangeListener (see FilterTable).
It would be great if you made the source available in a repository, and preferably in Maven format.
Jean-François Lamy: Great widget, *should be standard feature of Table and TreeTable* !
But a few notes:
- the very first feedback when I showed this to a user was "it should be possible to filter as soon as I stop typing"
- so I went ahead and extracted the source from the jar
- and I created two maven projects, one for the jar, and one for the demo.
- and I made the requested improvementPlease find enclosed a zip file with the two Maven projects.
In my variation, FilterDecorator class now has one more method isTextFilterImmediate(Object propertyId). If this method returns true, then the TextField is created with a TextChangeListener (see FilterTable).
It would be great if you made the source available in a repository, and preferably in Maven format.
I second that. I still would like to use that for tree table and, Jean-François, I exactly wanted to implement that feature as well, you've been too fast, thanks !
Hi,
Todor Andreev: Hi,
The widget seams great, however I am having trouble compiling it. I get the following error on compilation:
...
[INFO] GWT Module org.vaadin.hene.popupbutton.widgetset.PopupbuttonWidgetset not found in project sources or resources.
I think you're missing the PopupButton jar from the widgetset build path. The FilteringTable requires also the PopupButton add-on, and it's included in the zip file. Please make sure that the compiler can find it while compiling the widgetset.
-Tepi
Hi,
Jean-François Lamy: Great widget, *should be standard feature of Table and TreeTable* !
But a few notes:
- the very first feedback when I showed this to a user was "it should be possible to filter as soon as I stop typing"
- so I went ahead and extracted the source from the jar
- and I created two maven projects, one for the jar, and one for the demo.
- and I made the requested improvement
Thanks! This does seem like a good feature. Of course one might want to be careful with the text change timeout expecially if each filtering event goes all the way to the database through an SQLContainer or something similar.
Jean-François Lamy: Please find enclosed a zip file with the two Maven projects.
In my variation, FilterDecorator class now has one more method isTextFilterImmediate(Object propertyId). If this method returns true, then the TextField is created with a TextChangeListener (see FilterTable).
It would be great if you made the source available in a repository, and preferably in Maven format.
I'll try to get it into github as soon as I have the time. I'll be sure to include your change :).
-Tepi
Hi,
Stéphane Nicoll: Your plugin suits exactly a use case I would like to implement this week. But I am using a tree table (and not a table). I guess FilterTable extends Table.
Any idea how hard it would be to suit this add-on to tree table as well? Also, I am happy to dig in the code and implement that myself. Is the code available somewhere?
Looking at the code of TreeTable (and VTreeTable) I don't immediately see an 'easy' way of integrating this add-on with it. I'll probably have to make a separate version of the add-on for TreeTable. I think most of the code can be reused though.
The source code of the add-on is currently available only in the add-on jar file, you can extract it from there. I'll try to get it into a repo as soon as I have the time for it.
-Tepi
Hi,
You were right, the problem was I was missing the PopupButton addon. Thanks! The addon is great, good job.
I found one issue however, If I have my table placed in a horizontal spit layout, for some reason the search text fields get disabled and I am not able to perform any searches. Any suggestions??
Thanks in advance
Teppo Kurki: ...Of course one might want to be careful with the text change timeout expecially if each filtering event goes all the way to the database through an SQLContainer or something similar..
Perhaps decorator methods could have variations to set the setInputEventTimeout() and perhaps the LAZY/TIMEOUT method of the text field. We actually use the field with SQL-based containers and the default behaviour is actually pretty good (waits just long enough before reacting)
Hi there.., This component seems to suit our requirements very well. I have a couple of questions on this, please help me with this.
1. I would like to know if we can populate the filters with dynamic values than using an enum.
2. Is there a way to give check box as a filter?
2. And is there a way to hide filters for some of the columns.
3. Does this work with paging, I mean how can I make a db call from this, can I add any listener and filter the data?
4. Is there a way to show the default option as All insted of empty value in the filter?
Pls help me by answering these.
Thank you.
I had a quick look at the code
1. Anything you want, since you can generate the filter as you wish.
2. Not currently -- though this would not be difficult to do since a simple field is used.
3. Not currently -- though this would probably be easy to add.
4. Paging is done by the underlying container. So if you use a paging containert hat implements the Filterable interface such as JPAContainer, JPA Criteria LazyQueryContainer, etc. it will work just fine.
5. Not sure.
1, 2, 4 and 5 would be easily handled if there was a FilterFieldGenerator in addition to the decorator. The current code is just a 20-line routine that, at first glance, could be factored out.
Hello Jean.., Thanks for the quick response, we are evaluating vaadin for one of our new project, is there a way to extend filtering table to accommodate these requirements?
For the first requirement, the filter generator is only providing the ability to change the values, but not providing the ability to bind the list of values.
And also there is another issue with this component, the headers are not matching the filters, attached a screenshot, do you see any fix for it pls?
Looking at the source, it seems straightforward to add a method to the FilterGenerator, one that would create the corresponding field use for filtering. In the database filtering case it would return a select bound to the desired values. Something like getFilteringField() would make sense to me. In that way, one could do a select in a database, find all unique values in the column, and create a select based on that. Voilà, instant Excel-like filtering.
Something like that is likely less than a day of coding/testing. Hopefully Tepi is following the discussion and can add that in. Else, either you or me or anyone else can add it if we need it. That's what open source is all about...
Rajesh Mulcha:
And also there is another issue with this component, the headers are not matching the filters, attached a screenshot, do you see any fix for it pls?
I am not the author, Tepi is. Whereas I am quite comfortable with the server-side stuff, I've never had much need to look at the client-side rendering. So someone else will need to pitch in.
I am using a PagedTableContainer as the datasource for a FilterTable, but my <div class="filters-panel"></div> shows up empty, could this be because
PagedTableContainer
implements Container, Container.Indexed, Container.Sortable
whereas IndexedContainer used in the example also implements
Container.PropertySetChangeNotifier, Property.ValueChangeNotifier,
Cloneable, Container.Filterable,
Container.SimpleFilterable
Looking at the current source for PagedTable (via the add-on directory) , I see
public class PagedTableContainer implements Container, Container.Indexed,Container.Sortable {
I have tested with JPA Criteria LazyQueryContainer which implements Filterable, and things work fine.
so i would have to implement Filterable in LQC, the default implementation in add-on directory does not implement it.
This is the reason I started work on JPA 2.0 Criteria LQC -- I wanted to be able to use the standard JPA 2.0 API for creating filters without manipulating textual SQL. JPA 2.0 Criteria LazyQueryContainer is actually a wrapper, it delegates most calls to LQC and does not modify it.
In Vaadin 6.6,. Filterable was added, and Vaadin now supports it in SQLContainer and JPAContainer, should you prefer those over JPA 2.0 Criteria LQC.
Managed to get it to suit my needs by implementing Container.Filterable in PagedTableContainer, thanks for the quick response.
Hi,
As I mentioned before there is an issue with the search boxes being disabled. I thought its caused by having my table in a split panel but I was wrong. Apparently the issue is with having the table in a tabsheet, and only with the tab that is being select on starting up the application. So the scenario is I have a table on tab1 which is the default tab to open when the application is started, and search boxes are disabled there. Then I have a filter table on tab2, which if I open up has all search boxes enabled. If I try returning to tab1 search boxes are still disabled.
Any suggestions?? Thanks!
Hi Rajesh,
Thank you for trying out FilterTable. It is still work in progress so please pe patient :). I'll try to fix the issues raised here as soon as I have the time.
Rajesh Mulcha: For the first requirement, the filter generator is only providing the ability to change the values, but not providing the ability to bind the list of values.
Just to make sure I understood correctly: You would like to define e.g. a ComboBox with a set of different filtering options, and selecting one of these options would return a custom Filter that would be applied to the column? I think this would be quite simple to implement.
Rajesh Mulcha: And also there is another issue with this component, the headers are not matching the filters, attached a screenshot, do you see any fix for it pls?
I think this is due to the different theming you are using. I have actually only tested the FIlteringTable with the Reindeer theme of Vaadin. I'll look into it and see if it could be fixed.
-Tepi
Hi Todor,
Todor Andreev: As I mentioned before there is an issue with the search boxes being disabled. I thought its caused by having my table in a split panel but I was wrong. Apparently the issue is with having the table in a tabsheet, and only with the tab that is being select on starting up the application. So the scenario is I have a table on tab1 which is the default tab to open when the application is started, and search boxes are disabled there. Then I have a filter table on tab2, which if I open up has all search boxes enabled. If I try returning to tab1 search boxes are still disabled.
Thanks for your bug report. Unfortunately I don't have any immediate suggestions on what could be wrong and how to fix it. I'll try it out myself and see what's wrong.
-Tepi
Great addon! Is there anyway to have this working along with the Export table addon?
Hi,
How can we move forward with the tree table thing. Can you provide some guidance?
Thanks,
S.
Hi there,
Just as info... I realized that the width of the filter boxes are okay when I use the chameleon theme... Maybe that helps. Anyway: great add on. Saved my life.
Regards
Schlomo
Hi,
Is there a way I can reset all values in the filters to null, say by clicking on a refresh button, so that I can get the full result of my data container? Because for example if you have 40+ fields is quite inconvenient to scroll to say column 31 to delete the value so you can get full set as well.
Thanks in advance!
I have taken a stab at refactoring FilterGenerator so that it generates both the Field used for capturing the desired value(s) and the Filter that does the corresponding processing.
This allows, for instance, creating a filter based on the actual contents of a table column (select distinct values, create a select from that, and use it as the filtering field, much like excel does).
I'm hoping to post an update of my variant sometime next week. Tepi, how far along are you in setting up a source repository for your code? I'd rather not create a fork.
Jean-François Lamy: I have taken a stab at refactoring FilterGenerator so that it generates both the Field used for capturing the desired value(s) and the Filter that does the corresponding processing.
This allows, for instance, creating a filter based on the actual contents of a table column (select distinct values, create a select from that, and use it as the filtering field, much like excel does).I'm hoping to post an update of my variant sometime next week. Tepi, how far along are you in setting up a source repository for your code? I'd rather not create a fork.
Can't we just push that somewhere on github and be done with it? I'd also like to give a shot a tree table support and doing that out the blue is something I'd like to avoid.
Teppo Kurki: Hi,
there's a Git repo now available here. Patches are very welcome, especially regarding the TreeTable support :).
-Tepi
Ah nice! That would be my first client-side change to Vaadin. I guess most of the code would be shared.
I'll have a look.
Thanks,
S.
Hi again,
Teppo Kurki:
Todor Andreev: As I mentioned before there is an issue with the search boxes being disabled. I thought its caused by having my table in a split panel but I was wrong. Apparently the issue is with having the table in a tabsheet, and only with the tab that is being select on starting up the application. So the scenario is I have a table on tab1 which is the default tab to open when the application is started, and search boxes are disabled there. Then I have a filter table on tab2, which if I open up has all search boxes enabled. If I try returning to tab1 search boxes are still disabled.
Thanks for your bug report. Unfortunately I don't have any immediate suggestions on what could be wrong and how to fix it. I'll try it out myself and see what's wrong.
I now had the time to try out the bug you described but I could not reproduce it. I added two tabs to a tabsheet that is visible in the application main window. Both tabs contain a filter table. Regardless of which tab is selected at application start, the tables in both tabs function normally. I tested with Vaadin 6.7.5. If you're still having the issue, please provide a simple test case on how to reproduce the bug. Thanks.
-Tepi
Ok, I didn't have my tabsheet set to setEnabled(true). When I added this it fixed the problem.
Btw I mentioned before if there is a way to clear the filter boxes you can see my reasons above. Any suggestions here?
Thanks!
Teppo Kurki: Hi,
Stéphane Nicoll: Your plugin suits exactly a use case I would like to implement this week. But I am using a tree table (and not a table). I guess FilterTable extends Table.
Any idea how hard it would be to suit this add-on to tree table as well? Also, I am happy to dig in the code and implement that myself. Is the code available somewhere?
Looking at the code of TreeTable (and VTreeTable) I don't immediately see an 'easy' way of integrating this add-on with it. I'll probably have to make a separate version of the add-on for TreeTable. I think most of the code can be reused though.
The source code of the add-on is currently available only in the add-on jar file, you can extract it from there. I'll try to get it into a repo as soon as I have the time for it.
-Tepi
Hi Tepi,
Do you intend to put your changes to Table (in CustomTable) back to Vaadin itself? Because TreeTable extends from Table and I would have to basically copy/paste the TreeTable class as well. Which is probably a very bad idea when Vaadin will add improvements in Tree/TreeTable (or fix bug!)
What is the strategy to ensure this add-on can follow upcoming changes in Vaadin. Wouldn't that be a candidate for the core framework actually?
Thanks,
S.
Hi,
Stéphane Nicoll: Do you intend to put your changes to Table (in CustomTable) back to Vaadin itself? Because TreeTable extends from Table and I would have to basically copy/paste the TreeTable class as well. Which is probably a very bad idea when Vaadin will add improvements in Tree/TreeTable (or fix bug!)
Seems you've reached the root of the problem, which boils down to the Table/TreeTable being basically unextendable. Unfortunately I do not have the authority to just add this to core Vaadin, but if you want to help please create an enhancement ticket in our trac. I thought one existed already but I could not find it. I'd say Vaadin 7 should at least at some point help with this issue but of course there's still some time until that'll happen.
Stéphane Nicoll: What is the strategy to ensure this add-on can follow upcoming changes in Vaadin. Wouldn't that be a candidate for the core framework actually?
For 'full' support I should of course provide different versions of FilteringTable for different Vaadin versions (starting from 6.7.5) and port back bug fixes or added features. In practice I will probably not have time to do the feature back porting for the previous versions so I'll most likely only add new features to the most recent version (I'll try to get a version fro 6.7.6 out this week). Again, please do create an enhancement ticket to the Vaadin trac if you feel this is something that should be included in the core.
-Tepi
Teppo Kurki: Hi,
Stéphane Nicoll: Do you intend to put your changes to Table (in CustomTable) back to Vaadin itself? Because TreeTable extends from Table and I would have to basically copy/paste the TreeTable class as well. Which is probably a very bad idea when Vaadin will add improvements in Tree/TreeTable (or fix bug!)
Seems you've reached the root of the problem, which boils down to the Table/TreeTable being basically unextendable. Unfortunately I do not have the authority to just add this to core Vaadin, but if you want to help please create an enhancement ticket in our trac. I thought one existed already but I could not find it. I'd say Vaadin 7 should at least at some point help with this issue but of course there's still some time until that'll happen.
Stéphane Nicoll: What is the strategy to ensure this add-on can follow upcoming changes in Vaadin. Wouldn't that be a candidate for the core framework actually?
For 'full' support I should of course provide different versions of FilteringTable for different Vaadin versions (starting from 6.7.5) and port back bug fixes or added features. In practice I will probably not have time to do the feature back porting for the previous versions so I'll most likely only add new features to the most recent version (I'll try to get a version fro 6.7.6 out this week). Again, please do create an enhancement ticket to the Vaadin trac if you feel this is something that should be included in the core.
-Tepi
I definitely think it would be very valuable to add this to the core. I created #8548
It's a very nice add-on.
I tried using it with a BeanItemContainer but I ran into a NullPointerException when calling FilterTable.setContainerDataSource() method:
java.lang.NullPointerException
org.tepi.filtertable.FilterTable.createField(FilterTable.java:291)
org.tepi.filtertable.FilterTable.initializeFilterFields(FilterTable.java:270)
org.tepi.filtertable.FilterTable.setContainerDataSource(FilterTable.java:130)
The container is empty at this point. Any ideas?
Thanks,
Mika
I just released version 0.5.1 of the FilteringTable add-on. The changes are listed below:
• Fixed filter field width issue - should now work with virtually all themes
• Added support for text change events per property ID (thanks to Jean-François Lamy)
• Added method to adjust text change event timeout per property ID
• Removed the need to set the FilterDecorator before the container
• Added a getter for filter bar visibility state
• Added a resetFilters method
• Now preserves filter bar visibility state over container/decorator change and filter reset
These are all issues brought up in this thread, so I'd like to thank you for all the bug reports and enhancement requests. The 0.5.1 version is still based on the Table in Vaadin 6.7.5.
Please try out the new version and keep the bug reports and feature requests coming in!
-Tepi
The one important feature still missing (which I had started and almost done) is the ability to set the FilterField as a custom select (or any other itemization field). One obvious use is to get all the distinct values in a column, and allow the user to filter on them (just like Excel or LibreOffice Calc do). I got sucked into a real job black hole, and won't emerge until April I'm afraid. So unless I get a lucky break I won't be contributing anything for a while.
Version 0.5.2 of FilteringTable released. The only change is that this version is based on the Table from Vaadin 6.7.6. Some quite annoying bugs were fixed in that version so it's probably for the best to move to this version.
Demo application is updated too. New features in the demo are the reset button and a text change listener for the 'name' column filter.
-Tepi