Problems displaying DTO collection loaded by a load delegate

Hi!

I have a problem displaying a list of DTO’s in a table. My DTO (simplified):

@Getter
@Setter
@JmixEntity
public class PriceReportRowDTO {
    @JmixId
    UUID id;
    @InstanceName
    private String name;
// other fields...
}

Data is fetched with a custom repository, so I use a load delegate in my screen to get the data. The screen is:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://jmix.io/schema/ui/window"
        caption="msg://priceReportScreen.caption">
    <data readOnly="true">
        <collection id="priceReportDc" class="com.advance.agent.entity.PriceReportRowDTO">
            <loader id="priceReportDl"/>
        </collection>
    </data>
    <facets>
        <dataLoadCoordinator auto="true"/>
    </facets>
    <layout>
        <table id="productsTable"
                      width="100%"
                      dataContainer="priceReportDc">
            <columns>
                <column id="name"/>
            </columns>
        </table>
    </layout>
</window>

Controller:

@UiController("PriceReportScreen")
@UiDescriptor("price-report-screen.xml")
public class PriceReportScreen extends Screen {
    @Autowired private PriceReportRepository priceReportRepository;

    @Install(to = "priceReportDl", target = Target.DATA_LOADER)
    protected List<PriceReportRowDTO> priceReportDlDelegate(LoadContext<PriceReportRowDTO> loadContext) {
        return priceReportRepository.getReportRows();
    }
}

After all I get an empty table, although priceReportDc has all the data after the screen is loaded. What am I doing wrong?

I’ve also tried to load another object (not a DTO) using a query in the xml and that worked well with the same code.

UPD: actually I found that the problem is not in the delegate but in my DTO class. If I return a list of entities from a load delegate, there is no problem.

Hi Vadim,

Could you provide a test project?
This example looks exactly like yours and it definitely works:

Hi Konstantin,

Thank you for your reply! The problem turned out to be really stupid. My DTO class just was not declared in the role file, so a user didn’t have access to it. I’m sorry for disturbing.

Hello Konstantin,
working for the first time on loadDelegate now, I cannot find the needed documentation…

Actually,
where in your example does TaskService come from? And is that needed?

Thanks,
Br
HP

Hello Hans-Peter,

Look into this example project: https://github.com/jmix-framework/jmix-samples-2/tree/main/external-data-sample#readme

TaskService is just a Spring bean which does the loading. And loadDelegate invokes it.