Table, preventing refreshRowCache or transactional refresh

Hi,

A number of Table methods end up calling refreshRowCache() to propagate changes resulting from a new state of the Table instance.

However, that can be computationally inefficient, especially when the table is already populated and one a priori intends to make several calls to such methods, eg. to alter the overall structure of the table. Specifically, I’m thinking about the addGeneratedColumn/removeGeneratedColumn for instance, or setEditable, setVisibleColumns, …

So far, in order to emulate a transactional state approach and delay/minimize the UI updates, I subclassed Table to add freeze()/release() methods and overrode refreshRowCache() to only call the super implementation if the current state is !frozen.

TransactionalTable table = new TransactionalTable();
...
[color=#008000]
/*
 * will set frozen to 'true'.
 * Any calls to refreshRowCache() will be aborted
 */
[/color]
[color=#0000CD]
table.freeze(); 
[/color]

table.setEditable(true);

for(Object columnId : columnsToGenerate) {
   table.addGeneratedColumn(columnId, someGenerator);
}

table.setVisibleColumns(setOfVisibleColumns);

[color=#008000]
/* will set frozen to 'false' and call super.refreshRowCache() */
[/color]
[color=#0000CD]
table.release();
[/color] 

Although that does the trick just fine (with release() ultimately calling super.refreshRowCache()), I was hoping that someone here could share their own experience in dealing with this issue or hopefully provide a more general way of handling this.

Any insight into this/
best practice
would be very much appreciated. Many thanks!

Hi,

I recognize this issue too and afaik there’s no reasonable solution to it, outside the manual implementation. Please do note the disableContentRefreshing and enableContentRefreshing methods in the Table class - you can use those to do your own implementation. They are currently used internally within the Table to minimize the amount of refreshes, but obviously the Table can’t know when the updates are complete and you’ll still get some unwanted refreshes.

Hi Teppo,

Thanks, I came across those too eventually and ended up implementing my own Table with them anyway. I’d help a lot those two methods public, with the risk of forgetting to reenable content refreshing. But that would be noticed immediately anyway.

Disabling refreshes can really make a world of difference on a large table with components, etc…

Cheers
OKI