HbnContainer question

Hi All!

Do I understand correctly that if I have a table with n-fields, and if I use the method addContainerFilter for each field in this table, the container will be updated n-times?

Thanks!

Hi!

Yes, if I understood correctly :slight_smile:

With all containers (including HbnContainer) and Vaadin Table it is often the most efficient pattern to first configure table and datasource, then add the datasource to Table and then add the Table to UI. With this method Table needs to update its row cache only once. If you connect the data source earlier to table and then filter it (or modify tables column or populate container etc) table may need to update its row cache several times although it is not even rendered.

Why so? That’s a long story that you probably don’t want to hear, but it relates to the feature that there may be components in Table’s cells.

cheers,
matti

Thanks, Matti, for the answer!

Just my situation is - I have a table in the first show without a filter. Then the user selects the filtering conditions. If a small number of conditions, the number of calls to the database also is not great. But when the number of conditions above, the lowers performance. So I thought, is not it better to activate the filter at the request of the developer. Example:


addContainerFilter(...) //1
addContainerFilter(...) //2
...
addContainerFilter(...) //n

<after call of some method like "applyFilter", which just call clearInternalCache(); fireItemSetChange();>

Why not? :slight_smile:

Hi!

An easy workaround for your issue (meta code):



table.setContainerDataSource(null);
datasource.addContainerFilter(...);
...
datasource.addContainerFilter(...);
table.setContainerDataSource(datasource);

cheers,
matti

Hi Matti!

Thank you, for workaround!

What you think about extended “builder” of HbnContainer filter?
Perhaps, you’ll create a abstract method that can realize a full hibernate criteria mechanism? :slight_smile:

Hi!

Override the protected getBaseCriteria() method. You can modify the query with standard Hibernate api there. Vaadin’s Container.Filterable just ain’t flexible enough in all cases.

cheers,
matti