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,
If you change the FilteringTable to a normal Table can you still make this issue happen? Would be nice to know whether it's an issue in the Table itself or a result of some of the modifications I have made.
It could also be useful if you could do this with the debug window visible, and let me know if there are any errors (e.g. an exception) shown there.
-Tepi
Hi,
I've a problem with filters rendering.
I've a BeanItemContainer for a FilterTable in which I've added some nested container properties.
The filter bar is correctly showing but only for the "original fields" of the table, not for the nested properties.
Is it a bug or I've missing something to do?
Thanks,
Matteo
Hello Tepi, I will try to change it to Table. For now I just uploaded the sample app to: http://146.255.34.72/scrolling so that you can take a look on it.
You have higher probability of getting this problem after clicking "Refresh table" button and then scrolling.
I will let you know it the problem remains there even with Table component.
Hi,
The nested properties are not currently supported at all. I'll add this to my list of todo's for this addon but I really cannot promise any schedule for it. If you decide to not wait and implement it yourself, please post a patch for the addon :)
-Tepi
I've tried to simulate the problem with debug window. I cannot see any exception in debug window (see http://dodek.sk/share/scrolling2.log). But to be honest, I'm not sure what to look for.
Screenshot: http://dodek.sk/share/scrolling2.png
Sorry about that - the exceptions will be in red text in the debug window - you will surely notice :). Can't see any exceptions in your log paste though.
I did try your application with Firefox 15.0.1 and could not reproduce this after 10-15 counts of refresh and random scrolling. Does it only happen on specific browser and how many tries does it usually take to happen?
-Tepi
Tepi, it looks its quite random. I created screencast where you can see how I reproduced it in google chrome. But I was able to reproduce it also in Firefox. On two different laptops. (if you are not able to play this video, let me know, I will try to convert it to different format).
http://dodek.sk/share/scrolling-chrome.avi
In this video I used mouse to drag scrollbar, but was not able to reproduce the problem. Then I used mousewheel to scroll, and you can see the result.
(EDIT)
Here is video with firefox: dodek.sk/share/scrolling-firefox.avi
Here I didn't use mouse wheel, just scrollbar.
Ok, I get it now too - just have to scroll really fast, at least on my computer.
On the issue itself - I don't think this has anything to do with the FilteringTable add-on, so your best bet would be to swap it out for a common Table and then provide a (simplified) test case to the ticket you already mentioned. Please let me know how if the problem does not appear with the common Table component.
-Tepi
You were right, the same problem is with vaadin Table component. I added new comment to that ticket: http://dev.vaadin.com/ticket/6160#comment:3
Hi,
First of all thanks for very useful add-on.
Nevertheless found an issue with layouts. Say if filtersbar is not visible there is a scroll bar in the bottom of the table that allows to scroll to the right, but when filters set to visible this scrollbar disappears. Can attach screenshots if this has never been seen before.
Thanks
Cool!
Is it possible to use
public String getDateFormat(Object propertyId)
in FilterDecorator insted of DateFormat (as return type), in order to set the date format to the DateFields?
How can I change the date format of DateFields in DateFilterPopup?
Hello!
At first I want to thank you for the great plugin!
I use the newest Version 0.6.1 with Vaadin 6.8.3 and get some NotSerializableExceptions.
Okt 16, 2012 2:27:47 PM org.apache.catalina.session.StandardManager startInternal
Schwerwiegend: Exception loading sessions from persistent storage
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.tepi.filtertable.FilterFieldGenerator
Do you already know the problem and perhaps how it could be solved?
I have no issues in my program, but I think that there should not be such an exception at all...
Bye!
Hi Teppo,
Thanks for the addon, it works great, but there is an issue when using it with maven.
The jar file of this plugin is compliled without debug option, so you can't use debugger in the compiled classes. Of course, it is not critical, but it would be much better if you turn on debug option in future versions. Thanks
Hello. I am using filtering table in a project. Really great add-on as many people have already mentioned. I implemented my own filter popup with multiple checkboxes.
So filtering is done by checkboxes value changes. At first I did not used setPopupVisible(false) as it is done in DateFilterPopUp on each value change. On table with small amount of data, when I clicked on checkboxes everything worked fine and pop up was visible, but with large amount of data in the table pop up just disappears(!) and when you click on popup nothing happens(!). Interesting, that if you just refresh page in the browser, pop up is shown(!)/ So I`ve tried setPopupVisible(false) and it works fine, but it is not comfortable if you want to "click" on a lot of checkboxes (you need to click on pop up each time as it is not visible). I guess that this problem could happen with DateFilterPopUp if there had been no setPopupVisible(false) on "Set" function.
Maybe someone has ideas what can be the root of this problem and how this can be fixed?
Thanks in advance.
The DateFields in the DateFilterPopup use the application's locale setting. So you can just call setLocale(whatever) on your application instance and that will be used. By default this is set from the browser preferences of the user.
-tepi
Hi,
this exception is thrown because FilterFieldGenerator does not implement Serializable. I'll have that class implement Serializable in the next release. Thanks for noticing!
-tepi
Hi,
a fix for this issue was provided by 'vimukthi-git', thank you very much! I'll include the fix in the next release.
-tepi
Hi,
I can't immediately say what could be the reason for this. I'll try to look into it when I have some more time. In the meantime, could you consider using a button in your checkbox-popup like the one used in the datefilterpopup? This should eliminate the issue, of course it's probably not as nice a solution if the user has to click Ok.
-tepi
We are using FilterTable in our project. We went from 0.5.3 to 0.6.1. One thing that happened is that DateFilter() is now gone. What do we use in place of it?
Hi,
the DateFilter was remove because it was pointed out to me that it's actually useless and causes more problems than it solves :) You should use the built in filters of Vaadin instead:
com.vaadin.data.util.filter.Between
com.vaadin.data.util.filter.Compare.GreaterOrEqual
com.vaadin.data.util.filter.Compare.LessOrEqual
For an example on how to use these, please see the FilterFieldGenerator.java lines 96 - 104 in the latest FilteringTable version.
Hope you'll manage to use the built-in filters :)
-tepi
Hi!
Thank you for providing the plugin with the Serialized class!
Unfortunately I have a lot of Exceptions when I want to filter columns with integers in it.
com.vaadin.event.ListenerMethod$MethodException: Invocation of method buttonClick in org.tepi.filtertable.numberfilter.NumberFilterPopup$2 failed.
...
Caused by: com.vaadin.event.ListenerMethod$MethodException: Invocation of method valueChange in org.tepi.filtertable.FilterFieldGenerator$2 failed.
...
Caused by: java.lang.RuntimeException: Creating number filter has failed.
...
Caused by: java.lang.NoSuchMethodException: int.valueOf(java.lang.String)
There seems to be a problem in the standard filter that is used.
It would be very nice if you could fix the problem or give a quick workaround :-)
EDIT: Another question: Is it possible to turn off the new "greater than", "smaller than" and "equals" button and get back the old textfield?
Thank you!
Hi,
could you share the relevant code? If you look at the demo application, the column named 'id' is of type Integer and the popup-style filtering works correctly. I'll look into providing the previous functionality also.
Thanks for the feedback!
-tepi
Dear Tepi!
Thank you for the quick reply!
I used the plugin with only little modifications in the TableFilterDecorator and TableFilterGenerator classes.
So I will show you my implementation:
TableFilterDecorator:
public class TableFilterDecorator implements FilterDecorator, Serializable {
@Override
public String getEnumFilterDisplayName(Object propertyId, Object value) {
return null;
}
@Override
public Resource getEnumFilterIcon(Object propertyId, Object value) {
return null;
}
@Override
public String getBooleanFilterDisplayName(Object propertyId, boolean value) {
return null;
}
@Override
public Resource getBooleanFilterIcon(Object propertyId, boolean value) {
return null;
}
@Override
public String getFromCaption() {
return "Startdatum:";
}
@Override
public String getToCaption() {
return "Enddatum:";
}
@Override
public String getSetCaption() {
// return null = use default caption
return "Los!";
}
@Override
public String getClearCaption() {
// return null = use default caption
return "Löschen";
}
@Override
public boolean isTextFilterImmediate(Object propertyId) {
return true;
}
@Override
public int getTextChangeTimeout(Object propertyId) {
// TODO Auto-generated method stub
return 0;
}
@Override
public int getDateFieldResolution(Object propertyId) {
return 4;
}
@Override
public DateFormat getDateFormat(Object propertyId) {
return null;
}
@Override
public String getAllItemsVisibleString() {
// TODO Auto-generated method stub
return null;
}
@Override
public NumberFilterPopupConfig getNumberFilterPopupConfig() {
NumberFilterPopupConfig config = new NumberFilterPopupConfig();
config.setEqPrompt("gleich");
config.setGtPrompt("größer");
config.setLtPrompt("kleiner");
config.setOkCaption("Los!");
config.setResetCaption("Löschen");
return config;
}
}
TableFilterGenerator:
public class TableFilterGenerator implements FilterGenerator, Serializable {
@Override
public Filter generateFilter(Object propertyId, Object value) {
// For other properties, use the default filter
return null;
}
@Override
public AbstractField getCustomFilterComponent(Object propertyId) {
// TODO Auto-generated method stub
return null;
}
@Override
public void filterRemoved(Object propertyId) {
// TODO Auto-generated method stub
}
@Override
public void filterAdded(Object propertyId, Class<? extends Filter> filterType, Object value) {
// TODO Auto-generated method stub
}
}
And here is the use in my table:
public class PatientBrowserList extends FilterTable {
public PatientBrowserList() {
// number of rows in the table
setPageLength(20);
// some UI settings
setSelectable(true);
setWidth("100%");
// FilterTable related stuff
setFilterDecorator(new TableFilterDecorator());
setFilterGenerator(new TableFilterGenerator());
setFilterBarVisible(true);
}
Thank you very much!
Jens
Hi,
I copied your code directly from your post and could not produce any exceptions. What you left out though is what kind of container you have and what it contains when the issue is present. I just created a dummy IndexedContainer with some Integer, String and Date properties. If you still have this problem, please also provide info on your container and I might just get the issue reproduced.
-tepi
Hi Tepi!
I use a Java class from where a BeanItemContainer is created and attached to the table.
The following code shows the relevant variables that are crashing:
public class Patient extends DatabaseObject {
protected int patientID;
protected int patientIDSap = 0;
public int getPatientID() {
return patientID;
}
public void setPatientID(int patientID) {
this.patientID = patientID;
}
public int getPatientIDSap() {
return patientIDSap;
}
public void setPatientIDSap(int sapPatientID) {
this.patientIDSap = sapPatientID;
}
There is a lot of things around for the communication with the database i suppressed here,
but that are the main parts causing the problem.
The other fields for Strings and Date and so on are working perfectly.
BTW: I found another NotSerializableException, perhaps you could fix it in the next release :-)
IOException while loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.tepi.filtertable.numberfilter.NumberInterval
Jens
Hello Tepi,
I made a very small update on FilterTable.java to permit non String propertyIds for setFilterFieldValue. Please check the pull request on Github.
Thanks,
Tibi
Hi,
and thanks for noticing that! I just merged your changes and they will be included in the next bugfix-release.
-tepi
Hi,
I figured out what was wrong and it is now fixed in a new version I just uploaded to the directory, 0.7.1. Basically it was down to using basic data types in the Patient bean in your BeanItemContainer. Apparently java's reflection does not do autoboxing so it tried to call int.valueOf which obviously does not exist.
Numerous other issues were fixed as well, more details can be found in the release notes in the add-on's directory page.
-tepi
Hi Tepi!
Thank you very much!
I will test it immediately!
EDIT: Works like a charme :-)
And thank you for giving the possibility to disable the popup button for integers!
Thanks for the nice add-on. I'm just getting started with it and found that a NativeSelect does not work as a custom filter component on IE8 or Chrome, but it does work fine on Firefox. I put it into a stripped down test application for you to try.
Just as I was about to post this, I noticed you released v0.7.1, so I updated to it and Vaadin 6.8.5, but that didn't help. As a last try, I switched to a Select instead of NativeSelect, and that works on all browsers! Unfortunately Select is based on a TextField which always allows users to type rather than just bringing up the limited options.
package com.example.vaadintest;
import java.util.Random;
import org.tepi.filtertable.FilterGenerator;
import org.tepi.filtertable.FilterTable;
import com.vaadin.Application;
import com.vaadin.data.Container;
import com.vaadin.data.Container.Filter;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.data.util.filter.Compare;
import com.vaadin.ui.*;
public class VaadinTestApplication extends Application
{
private FilterTable filterTable;
public void init()
{
Window mainWindow = new Window("VaadinTest Application");
setMainWindow(mainWindow);
filterTable = buildFilterTable();
VerticalLayout mainLayout = new VerticalLayout();
mainLayout.setSizeFull();
mainLayout.setSpacing(true);
mainLayout.setMargin(true);
mainLayout.addComponent(filterTable);
mainLayout.setExpandRatio(filterTable, 1);
mainWindow.setContent(mainLayout);
}
private FilterTable buildFilterTable()
{
FilterTable filterTable = new FilterTable("FilterTable Demo");
filterTable.setSizeFull();
filterTable.setFilterGenerator(new MyFilterGenerator());
filterTable.setFilterBarVisible(true);
filterTable.setSelectable(true);
filterTable.setImmediate(true);
filterTable.setContainerDataSource(buildContainer());
return filterTable;
}
private Container buildContainer()
{
IndexedContainer cont = new IndexedContainer();
cont.addContainerProperty("id", Integer.class, null);
cont.addContainerProperty("severity", String.class, null);
Random random = new Random();
for (int i = 0; i < 100; i++)
{
cont.addItem(i);
cont.getContainerProperty(i, "id").setValue(i);
cont.getContainerProperty(i, "severity").setValue(random.nextBoolean() ? "WARNING" : "URGENT");
}
return cont;
}
private static class MyFilterGenerator implements FilterGenerator
{
public Filter generateFilter(Object propertyId, Object value)
{
if ("severity".equals(propertyId))
{
String v = (String) value;
if (v != null && !v.isEmpty())
return new Compare.Equal(propertyId, v);
}
return null;
}
public AbstractField getCustomFilterComponent(Object propertyId)
{
if ("severity".equals(propertyId))
{
NativeSelect box = new NativeSelect();
box.addItem("");
box.addItem("WARNING");
box.addItem("URGENT");
return box;
}
else
return null;
}
public void filterRemoved(Object propertyId)
{
}
public void filterAdded(Object propertyId, Class<? extends Filter> filterType, Object value)
{
}
}
}
Hi!
Thanks for the nice test case :) I identified the issue to some CSS problems which were quite straightforward to fix. A new version with the fix (0.7.2) is now available in the Directory. As a side note, I noticed that the NativeSelect on Chrome does not look as fitting to the filter bar as it does on e.g. Firefox, but I think there's not much that can be done about it.
-tepi
hi
im trying to make it work for a liferay portlet im working on but it fails. I put the two jar files in tomcat_home/webapps/ROOT/web-inf/lib and using the vaadin control panel, recompiled everything - it does find the jar files.
but when I open the page where I added the portlet it gives me a lot of exceptions and one if them complains about missing com.vaadin.ui.UniqueSerializable
im running liferay 6.0.X, vaddin 6.8.5 (latest as of today) and Your add-on is listed as supporting this and acutally not supporting vaadin 7+. I think the class com.vaadin.ui.UniqueSerializable is from vaadin 7, correct? is there a issue of mixing of vaadin version here or?
it seems that the com.vaadin.ui.UniqueSerializable is actually included within Vaadin 6.8.5, although it is only used by the Table component (and hence the FilteringTable also). Can you try to see inside your vaadin jar and see that the UniqueSerializable actually is there? Mine does have it (jar fetched with vaadin eclipse plugin) and seems to not create any problems.
I don't know why is this class included in vaadin 6. Event the javadoc states the following, indicating that it would belong to V7:
* @author Vaadin Ltd
* @version 6.8.5
* @since 7.0
must have misplaced the jar files somehow. After deleting, copying around a bit its working...
except I dont have a good picture of what to do or implement. It has no default behaviour? a bit naive, but I just changed my Table into a FilterTable in the hope that it would give me a textfield above all columns and then if I wrote something here it would filter based on string compare the rows that did equal.
but it does not show anything.
table.setFilterFieldVisible("Navn", true);
table.setFilterBarVisible(true);
I get a extra grey line below the headings and above the actual rows, but nothing where I can write anything or do anything.
I was looking at the example - its not up to date correct? The interfaces have changed, correct - at least "implements FilterGenerator" seams to have 4 methods I need to implement now, not just the one in the example. Can I leave the 3 new at returning null?
never mind found out it was due to the way I work with tables. It does not work when Im just adding Object[] to a table for rows even if I set the addContainerProperty on the table. I changed my code into doing a IndexedContainer and now its showing input fields and letting me filter "queals" on strings.
on to figuring out how to actually control the filtering :D
Thank you Tepi. That resolved it on all my test browsers: Firefox 16/Linux, Chrome 22/Linux, IE8/WinXP, and IE9/Win7.
A little contribute back for those like me who want the filter row to take up minimal space, these styles added to the application theme shrink it down, for TextField, Select, and NativeSelect (haven't tried others). Also, it sets the columns with no filters to blank white space. (The grey that was there doesn't match the Runo theme.)
.filters-panel {
background-color: #fff !important;
height: 18px !important;
}
.filters-panel .v-label,
.filters-panel .v-select,
.filters-panel .filterplaceholder {
height: 16px !important;
}
.v-table .filters-panel .v-textfield,
.v-table .filters-panel .v-select,
.v-table .filters-panel .v-filterselect {
height: 13px !important;
font-size: 11px !important;
}
.v-table .filters-panel .v-filterselect-input {
font-size: 11px !important;
}
.v-table .filters-panel .v-select-select {
font-size: 11px !important;
}
Tepi, would it be difficult to include source and javadoc .jar files in the releases? Each time there's an update (three times in two days now - thank you for being so responsive!), I have to download the plug-in, then the source code, and generate the Javadoc. Surely many others are doing the same. I don't want to burden you though - it's very nice of you just to contribute this.
- Adam
Hi Adam,
I just released another version :D but this time with javadocs and a separate sources jar package. Please tell me if this is close to what you wanted. The ant build script of the project will now also generate these if you want to check out the project and do it yourself.
And thanks for your styling mod, I bet a lot of users will find it usable. This addon is quite difficult in the theming respect since it integrates so heavily with an existing component, preveting me from just theming it 'independently'. For now I've decided to just support/use the default (reindeer) theme to limit the amount of work I need to do with the css.
Thank you... I wasn't expecting a new release just to put the source and javadoc in. It works well, except I still had to cd into the javadoc directory and run
jar cvf ../javadoc.jar *
Eclipse doesn't allow relative paths to a javadoc directory, but does allow a workspace path to a javadoc .jar. (I avoid absolute paths in my file system within projects files - since of course they won't work on other people's computers.) Other people may prefer to have it outside an archive so they can view it from a browser though.
I started using a numeric filter, so here's the style.css additions again to shrink the vertical space used by the filters - now with number filer popup support.
/* Override styles for FilterTable to use minimal vertical space */
.filters-panel {
background-color: #fff !important;
height: 18px !important;
}
.filters-panel .v-label,
.filters-panel .v-select,
.filters-panel .filterplaceholder {
height: 16px !important;
}
.v-table .filters-panel .v-textfield,
.v-table .filters-panel .v-select,
.v-table .filters-panel .v-filterselect {
height: 13px !important;
font-size: 11px !important;
}
.v-table .filters-panel .v-filterselect-input {
font-size: 11px !important;
}
.v-table .filters-panel .v-select-select {
font-size: 11px !important;
}
.numberfilterpopup {
height: 18px !important;
padding: 0px 6px !important;
}
.numberfilterpopup .v-button-wrap {
border: none !important;
height: 13px !important;
}
.numberfilterpopup .v-button-caption {
font-size: 11px !important;
}
.v-popupbutton.numberfilterpopup .v-popup-indicator {
height: 16px;
}
Hi, I'm facing some problems changing setVisible property of a FilterTable in a TabSheet. Please, could you investigate?
Could you add a bit more info on how to reproduce the problem? I tried both setting the Tab and the FilteringTable itself (within the tabsheet) visible/not-visible and could not notice any issues.