Not able to refresh view of table which has datasource as collectionpropertycontainer

Hi Everyone,

I have an entity A which is master and enity B which is attribute of entity A which has composition relation with master(Similar to order and orderlines).

In the Master entity Editor screen when i click on a “submit button” i will have to create programmatically entity B and add it to a table.
I am not able to get the updated view of the table after clicking “Submit button”.

I am using collectionpropertycontainer as a datacontainer for table and the property is set accordingly.

Below is my code snippet for button submit action:

  public void onBtnsubmitClick() {
        entityB stchng = dataCnxt.create(entityB.class);
        stchng.setSubmissionId(sub);
        stchng.setStatus("Success");
        stchng.setResult("Submitted");
        entityBDc.getMutableItems().add(stchng);
        entityBDc.setItem(stchng);

        dataCnxt.addPreCommitListener((context -> {
            context.getModifiedInstances().add(stchng);

        }));
  }

Please help me in resolving the issue.
Thanks in advance for the help.

Hi,

Firstly, the code dataCnxt.addPreCommitListener(...) is not needed, as long as you create the entity using DataContext.create() it becomes tracked by the context and will be saved on screen commit.

Secondly, make sure you set back reference to master entity, only in this case the link between the entities will be saved.

If it doesn’t help, please provide a test project where we could reproduce your problem.