1

I have form with Table. This table has some smart fields.

My problem is that when I fill data in table (by initialization) all smart fields call getDataByKey with id (what it right) but it is not called once what I would expect but 30 times.

I dig a little bit for answer and I discovered that function is called so many times, because inside class AbstractTable inside processDecorationBuffer the table with all calls m_cellLookupBuffer has a lot of calls stored inside (512 insted 9).

Has anyone the same problem?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Marko Zadravec
  • 8,298
  • 10
  • 55
  • 97

1 Answers1

0

When you have a SmartColumn in a table, scout needs to do the Lookup "key -> text" for each row. As you mentioned, in some cases it can be expensive. This is why there is an additional concept: BatchLookupCall / BatchLookupService.

The idea is to first collect all the rows and the required LookupCall and to process them in one batch.

To answer your question, I had to set up a small playground project. Here the key points I have noticed:

Type of your key

Batch LookupCall check the equals method of your call which relies on the equality of the key Object. If you are using a custom Type as key, ensure equals() and hashCode() is properly implemented.

Way of adding rows in the table

If you add the rows one after the other, like this:

Table table = getMyTableField().getTable();
ITableRow r;

r = table.addRow(table.createRow());
table.getTextColumn().setValue(r, "Lorem");
table.getMyColumn().setValue(r, 1L);

r = table.addRow(table.createRow());
table.getTextColumn().setValue(r, "Ipsum");
table.getMyColumn().setValue(r, 3L);

r = table.addRow(table.createRow());
table.getTextColumn().setValue(r, "Dolor");
table.getMyColumn().setValue(r, 1L);

r = table.addRow(table.createRow());
table.getTextColumn().setValue(r, "Figus");
table.getMyColumn().setValue(r, 4L);

Scout computes the table content too often… I could observe too many calls to the lookup service. I think there is some optimization possibility in this domain.

This does not happen if you import all your rows in one step, for example using the TableData included in the FormData or in the TablePageData.

Jmini
  • 9,189
  • 2
  • 55
  • 77