Instance loader in create screen of an entity

Hi Everyone,

I am currently working on a entity screen which has entity editor and a table with datacontainer related to another enity.
When user create or edit screen i want to populate the table based on the instance variable of the edit screen.
Below is my enitity editor screen xml.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>


    <instance id="lineofBusinessDc"
              class="com.company.esmdtest.entity.LineofBusiness"
              view="_local">

    <loader/>
      </instance>
    <collection id="ordersDc" class="com.company.esmdtest.entity.Error" view="_local" >
        <loader id="ordersDl">
            <query>
                <![CDATA[select e from esmdtest_Error e where e.lobid = ds$lineofBusinessDc]]>
            </query>
        </loader>
    </collection>
<dialogMode height="600"
            width="800"/>
<layout expand="editActions" spacing="true">
    <form id="form" dataContainer="lineofBusinessDc">
        <column width="250px">
            <textField id="nameField" property="name"/>
            <textField id="content_typeField" property="content_type"/>
            <checkBox id="is_esmd_claim_mandatoryField" property="is_esmd_claim_mandatory"/>
            <checkBox id="is_esmd_claim_displayedField" property="is_esmd_claim_displayed"/>
            <checkBox id="is_esmd_caseid_displayedField" property="is_esmd_caseid_displayed"/>
        </column>
    </form>
    <hbox id="editActions" spacing="true">
        <button action="windowCommitAndClose"/>
        <button action="windowClose"/>
    </hbox>
    <table id="ErrorTable" height="100px" width="200px" columnControlVisible="false" dataContainer="ordersDc" >
        <columns>
            <column id="test"/>
           </columns>
    </table>
</layout>

I am currently having problem loading the dataconatiner of the table when i create a new entity. I am getting error unknown parameter “ds$lineofBusinessDc”
Please help me in resolving the issue.

Thanks in advance for the help

Hello there.

Yes, the problem is that linking containers like this is not supported in V7. A step backward in my opinion (since I used it a lot), but all is not lost.

There is an example on how to implement similar functionality here:

Screen mixins

If regex isn’t your bag, then you can always do it the long way around, but that would mean implementing similar functionality for every page.

Dependencies between data components

I’m not sure how your entities are arranged, but if the orders collection has a defined relationship with the linesOfBusiness (a one-to-many defined in the class) then you might get away with something simple, like this:

    <instance id="lineofBusinessDc"
              class="com.company.esmdtest.entity.LineofBusiness"
              view="_local">

              <collection id="ordersDc" property="orders" />
        <loader/>
     </instance>
1 Like

Thanks for the reply.
I have created a collection in linesOfBusiness entity with a one-to-many relationship.
I am able to create a linesOfBusiness entity but when i edit the linesOfBusiness entity the collection is not being populated.
Could you please provide me any direction why the collection is not being populated

You need to subscribe to the ItemChangeEvent of the lineofBusinessDc and reload ordersDc like this:

@Subscribe(id = "ordersDc", target = Target.DATA_CONTAINER)
protected void onOrdersDcItemChange(InstanceContainer.ItemChangeEvent<Order> event) {
    orderLinesDl.setParameter("order", event.getItem()); 
    orderLinesDl.load();
}
1 Like