Embedded Attribute combined with inline editing

Hi,

in align with my last question i’ve encountered another situation that seems to be not correct. In this case it might more likely be the case that i just use it in an incorrect way, so i label it as a question here.

I’ve the following domain model: Company has Many Customers (composition). Customer has an attribute “address” as an embedded type.
I created an interface with a company editor that has a table of customers included. For this table i would like to have inline editing enabled. I did the following steps to get to the screen:

  1. generated the screen for the company entity with a “company-view” that holds all necessary data
  2. added the editable capability to the table
  3. changed column “address” in the table to “address.street” and “address.city”

Now when i try to store a customer and its address, the attributes of the address embedded only get stored when at least one of the direct attributes of the customer entity are changed (in case of editing an existing customer).

Can you tell me if i’m doing anything wrong regarding the datasources or do i have to call commit in the controller manually or anything?

Bye,
Mario

example-embedded-inilne.zip (84.0K)

Hi,

Changes in address are not saved because there is no datasource that can track changes of addresses. DsContext commits only tracked entities from datasources. To fix this behaviour in your screen you have to add nested datasource for address of a Customer.


<datasource id="companyDs"
            class="com.company.exampleembeddedinilne.entity.Company"
            view="company-view">
    <collectionDatasource id="customersDs" property="customers">
        <datasource id="addressDs" property="address"></datasource>
    </collectionDatasource>
</datasource>

This approach has limitations: you can only change addresses from the Table, because addressDs tracks changes only for current selected item of customerDs,. So, do not change your addresses programmatically. Unfortunately, pure solution requires much more coding and commit logic in your screen controller.