Deep Composition

Following the Deep Composition example all works well. But in the MeetingPoint Edit Screen, if I create new declarative nested datasources for meetingPointDs (would be airportDs and terminalDs), I receive :

java.lang.IllegalStateException: During synchronization a new object was found through ...

Why I receive this exception?. How could I use those parents datasources (airportDs and terminalsDs) from MeetingPointEdit?


To create datasources nested on the meetingPointDs, the meetingPointDs should be based on the view which includes required fields.
Look at the attached project. It illustrates how the Airport and Terminal could be accessed from the Meeting point browser and editor by the use of nested datasources. (38.5K)

1 Like

It throws again

java.lang.IllegalStateException: During synchronization a new object was found through ...

when you create a new Airport, a new Terminal (using the table terminalsTable CreateAction) and a new MeetingPoint (using the meetingPointsTable CreateAction).
How could I fix this?

Perhaps this is not the right approach.

Should I use the meetingPointDs.getItem() methods ( getTerminal() and getTermianl().getAirport() ) instead of terminalDs and airportDs , and remove these nestedDatasources?
In this case, when I create an Airport, a Terminal and a MeetingPoint and the three are in [new] state, changes over Terminal name are reflected when I open my modified meetingPointEdit screen, but not when the state is [detached].

Step by step:
First, when Entity state is [new]:

  1. Create new Airport, inside create new Terminal, inside create new MeetingPoint. (set all Entities name field)
  2. Commit MeetingPoint.
  3. Edit TerminalName.
  4. Open MeetingPointEdit. meetingPointDs.getItem().getTerminal.getTermName() its the previously changed.
  5. Commit MeetingPoint, commit Terminal, and commit Airport.

Second, when Entity state is [detached]:

  1. Open AirportEdit, open TerminalEdit and change TerminalName.
  2. Open MeetingPointEdit. meetingPointDs.getItem().getTerminal.getTermName() its not the previously changed.

This is my modified meetingPointEdit screen:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="[url=]"[/url];
        <datasource id="meetingPointDs"
    <layout expand="windowActions"
        <fieldGroup id="fieldGroup"
            <column width="200px">
                <field id="mpName"
                       caption="MP Name"></field>
        <pickerField caption="Terminal"
        <frame id="windowActions"

Solved setting “dirty” terminalDs datasource when terminalName changes.

public class TerminalEdit extends AbstractEditor<Terminal> {
    private TextField termNameField;
    private Datasource<Terminal> terminalDs;
    public void init(Map<String, Object> params) {
        termNameField.addValueChangeListener(e -> {
            ((DatasourceImplementation) terminalDs).setModified(true);

Exists a better solution?

The last solution not works well.

I can access to the parent datasource of the next way:

    public class MeetingPointEdit extends AbstractEditor<MeetingPoint> {

    private Datasource<MeetingPoint> meetingPointDs;

    protected void postInit() {
        if(getParentDs() instanceof NestedDatasource) {
            Datasource<Terminal> t = ((NestedDatasource) getParentDs()).getMaster();
            System.out.println(t.getItem().getTermName()); /*This work*/
        System.out.println( meetingPointDs.getItem().getTerminal().getTermName() );  /*This no work*/

This is the only manner I can do it.
Please, any suggestions?

You are right - nested datasources for parents break the deep composition editing.
So if you want to show parents on the bottom level of the composition (MeetingPoint.terminal, MeetingPoint.terminal.airport), you have to assign values to visual components directly:

<textField id="terminalName"
<textField id="airportName"

public class MeetingPointEdit extends AbstractEditor<MeetingPoint> {
    protected TextField terminalName;
    protected TextField airportName;

    protected void postInit() {

This will work for read-only fields, which I think is acceptable for the workflow when a user edits the whole composition: airport, then terminals, then meeting points. If you need a separate workflow, when a user can have a plain list of all meeting points from all airports, and is able to redefine parents for meeting points, use a separate edit screen for meeting points with nested datasources.

The working demo project is attached. I also fixed one more thing in it - the root editor (Airport) must contain the nested datasources for the whole composition including meeting points, even though it does not use meeting points datasource itself. (37.8K)