Hi Cuba Team,
I have a GroupTable with multiple generated columns.
I use a query with parameters in the xml definition with conditions which I set and then I call dataloader.load().
I also have the possibility to use the default filter component, because I want to use the pageing in the list. Everything works fine, but I have one major problem:
The column generater is called multiple times, sometimes up to x times where x is the number of rows in the result set.
this would probably not be a problem, but I fire a sql-statement in each row to get some additional data in the description of the button I generate.
Is there a way to ensure, that the button is created only once, and therefore the statement is called only once per row, or even better per visible row?
Right now, it makes the runtime unpredictable and very slow even when having not so many rows in the table.
@NotNull @Install(to = "jtAdressesTable.dataInfo", subject = "columnGenerator") private Component jtAdressesInfoColumnGenerator(DataTable dataTable) { Button btn = uiComponents.create(Button.class); Integer count = 0; count = dataManager.loadValue( "select count(e) from roman_DataTable e " + "where e.idMandant = :id_mandant and e.idAdresse = :id_adresse", Integer.class) .store(Const.dataStoreNameOracleData) .parameter("id_mandant", pdMandantService.getId()) .parameter("id_adresse", dataTable.getIdAdresse()) .one(); String desc = count != 1 ? String.format("%s Einträge", count):String.format("%s Eintrag", count); btn.setCaption(desc); btn.setWidthFull(); btn.addClickListener(clickEvent -> { openEditor(dataTable); }); return btn; }
Any help I would appreciate.
Regards
Manfred