Unable add dataloader for nested datacontainer

Hi team,
I’m using the sample-sales-cuba7 example, found that it’s unable to add data loader to nested datacontainer in Studio xml editor, for example to add DL for linesDc:
image
Though, the DL could be added in OrderEdit.java by programming.

Hi, @anjingjing!

You should not add data loaders for nested containers because they are Property Containers. These containers are using binding to the properties.

Regards,
Sergey

Hi @s.fedorov,
Thanks for your reply! But I need to add a filter to the collection property, similar case: add filter for OrderLine list table in OrderEdit page, so that when an order has many orderLines, I can use filter to view what i want to see. As the filter component request dataloader, so that i have to set dataloader for linesDc. Any other way to achieve this?

Since filter component works with query conditions you can not use it for nested containers. I can suggest two ways how to solve this problem:

  1. You could create separate container instead of nested to work with OrderLine list.

  2. You could use some custom filtering like the example from manual page.

Thank you! I tested with custom filtering and it works. Need to mention, i also tested create DL for nested DC, it also works, in OrderEdit.java:

    @Inject
    private Filter linesFilter;

    @Inject
    private InstanceContainer<Order> orderDc;

    @Inject
    private CollectionPropertyContainer<OrderLine> linesDc;

    @Inject
    private DataComponents dataComponents;

    @Subscribe
    private void onAfterShow(AfterShowEvent event) {

        CollectionLoader<OrderLine> linesDl = dataComponents.createCollectionLoader();
        linesDl.setContainer(linesDc);
        linesDl.setDataContext(getScreenData().getDataContext());
        linesDl.setView("orderLine-with-product");
        linesDl.setQuery("select l from sales_OrderLine l where l.order = :order");
        linesDl.setParameter("order",orderDc.getItem());

        this.linesFilter.setDataLoader(linesDl);
    }

This means, add DL for nested dataContainer did work. So I think this is some how an issue with Studio, because i can do this via Java but not able via xml, somehow inconstant.

The purpose of nested containers is to provide a tool for the automatic loading of properties of the master container. We do not support such use case with creation of data loader and in the future this may not work at all. Actually it can cause some bugs, because data binding is still there.

Regards,
Sergey

I see. thank you for detailed explanation!