How can I create a browse screen layout for a non-persistent entity?

Hi,

After creating a CUBA service bean that calls a REST service to get a List of Orders (from an external system), I’m trying then to set that list returned to a non-persistent Order CUBA entity.

Then this entity is used by a datastore used by a groupTable to display the list of orders, but even when I adding the entity list to the datastore, the list is not displayed on the screen.

I used this code:

public class PersonaBrowse extends AbstractLookup {


    @Inject
    private CustomerService customerService;
    @Inject
    private DataManager dataManager;
    @Inject
    private GroupDatasource<Persona, UUID> personaDs;

    @Inject
    private GroupTable<Persona> personaTable;

    @Override
    public void init(Map<String, Object> params) {
        List<Persona> personaList = customerService.getCustomerList();

        for (Persona persona: personaList
                ) {
            personaDs.setItem(persona);
        }
        personaDs.commit();
        personaDs.refresh();

        personaTable.repaint();
        
        //super.init(params);
    }

Any help will be welcome!
thanks n advance
Vicente

Hi Vicente,

The setItem() method is mostly used in simple datasources designed to work with one entity instance in entity editors.
As you want to populate your GroupDatasource, use the addItem() method instead:

List<Persona> personaList = customerService.getCustomerList();
for (Persona persona : personaList ) {
    personaDs.addItem(persona);
}
personaDs.refresh();

Committing the datasource is not needed here, neither is calling the repaint() method.