SimpleStringFilter and OptionGroup values

Hi everyone.
I have some filter problems.

Here is my configuration :

  • Table (of entities) binded to a Database (postgreSQL) with a LazyEntityContainer as DataSource
  • Entity “Bottle” (of wine actually :slight_smile: ) with a field “color” (String)
  • OptionGroup to select the color. It’s binded with a FieldGroup.
    —> FieldGroup fg = new FieldGroup(beanItemBottle);
    OptionGroup colorRadioButton = new OptionGroup(“Wine Color”);
    fg.bind(colorRadioButton, “color”);
  • A TextField where I write in to filter the table

Here is a little part of my code :
SimpleStringFilter filterColor = new SimpleStringFilter(“color”, event.getText(), true, true);

When I write “hi”, only white wine bottles are displayed/filtered in the table, that’s ok.

The problem is :
When I write “Whi”, nothing matches.

To summarize :

  • When I write the beginning of the color wanted, no matches.
  • When I write other parts, matches found.
    I don’t understand why.

I also tried :
And it works.

Very strange. Seems that the first Uppercase screw it up…

Any ideas ?

Very strange, taken from the SimpleStringFilter constructor source code, if you have put the ignoreCase parameter (3rd) to true, it does this:

this.filterString = ignoreCase ? filterString.toLowerCase() : filterString; So it should act the same way as lower case. Could you put a break point there and check that it is run with right parameters as well that it isn’t called multiple times. Maybe that could show something.

Also, regarding your bottleContainer.addContainerFilter(filterColor);, do you somewhere remove them aswell. I think if you just keep adding, then it will have to match all filters at once, by a wine being both red and white simultaneously. You might have the removal code somewhere else but it just raised a flag for me.

Thanks for your answer Mr. Jansson.

As you suggested, I put the breakpoint and ignoreCase is true. (you can see it in the attachment).
And yes, I remove all the filters before adding new ones.
Here is my code for filter:

TextField tf = new TextField();
tf.setInputPrompt(“Search Bottle”);

tf.addTextChangeListener(new TextChangeListener() {
public void textChange(TextChangeEvent event) {
String input = event.getText();
Filter filterColor = new SimpleStringFilter(“color”, input, true, false);

I reset the table container because if I only refresh the container, I strangely can’t see the update on the table.

I just tested many items with the method passesFilter() and it always returns true.
I think that the filter works but there’s a problem somewhere else, in the container or with the display maybe I don’t know.
So strange.
Is it possible to access the filter process deeper to see which items are filtered and how they are?


I’m not familiar with LazyQueryContainer so I skipped that part. It is a third party add-on - not a part of Vaadin itself, so I can’t talk much about the behaviour of it. I skimmed trough the code for it (at and here are some of the findings. I think you are right that creation and addition of filters goes correctly. Maybe it is a problem in how the container uses the filters?

Here are some key points in the code:

Filters goes into LazyQueryDefininition when you add them.
Items are stored in LazyQueryView.
Filters are applied to query in EntityQuery.setWhereCriteria(…);

It might be a problem with adding filters after initial query. From the (5 min) looks of it, it either throws away the whole cache and reloads all data when filters are added or then new filters aren’t applied correctly. You can probably see the queries themselves in some log? Maybe check those trough and see how the query changes before any filters and after? Sorry for not being able to give a definite answer.

I found what was the problem : PostgreSQL. Indeed, LIKE expressions are used. They are case sensitive. The best thing would be it uses ILIKE expressions which are case Insensitive (or I change database system).

Thanks for your help and time Mr Jansson.