Override the default Add Button

Hi,

I need to Override the default action Add Button:
I’ve tried:

@Subscribe("transactionsTable.add")
    public void onTransactionsTableAdd(Action.ActionPerformedEvent event) {
        screenBuilders.lookup(Transaction.class, this)      
               .withOptions(new MapScreenOptions(
                        ParamsMap.of("testValue", "Invoiced")))
                .build()
                .show();
    }

but when I open th screen the Select button is missing…

Regards,
-n

Hello,

in this case, you have to set selectHandler in order to enable “Select” button:

screenBuilders.lookup(Transaction.class, this)
        .withOptions(new MapScreenOptions(
                        ParamsMap.of("testValue", "Invoiced")))
        .withSelectHandler(transactions -> {
            transactionsDc.getMutableItems().addAll(transactions);
        })
        .build()
        .show();

But I think the simplest way is to use lookup with Table parameter:

screenBuilders.lookup(transactionsTable)
        .withOptions(new MapScreenOptions(
                        ParamsMap.of("testValue", "Invoiced")))
        .build()
        .show();

It works perfectly, thank you!
What is the difference between entityDc.getItems() and entityDc.getMutableItems()?

BR,
-n

  • getItems() returns “read only” collection, you cannot add or remove item.
  • getMutableItems() returns collection that every action (add, remove) will fire an event.

See this section for more details.

Thank you!