Entity change does not get reflected in visual Component

Hi there!

I have a problem with my Cuba application. I have following Edit screen:
image

When selecting a project the Project Technologies twin Column should look sth like this:
image

The options in the twinColumn are loaded from the selected project entity. The problem is, that the twinColumn refreshes only when I double click on it.

Here is my Code in projectExperienceEdit.java Controler:

public class ProjectExperienceEdit extends AbstractEditor<ProjectExperience> {

    @Override
    public void init(Map<String, Object> params) {
        // clear skills when project changes
        projectField.addValueChangeListener(e -> clearUsedSkills());
    }

    private void clearUsedSkills() {
        if (projektExperienceDs.getItem().getSkills() != null) {
            projektExperienceDs.getItem().getSkills().clear();
        }
    }
}

Here is my datasource layout:
image

projectExperienceDs: main Ds with the entity being edited
projectDs: options for the project Field
projectDs: options for the project Technologies twin Column

How do I refresh the twin Column when the project Field changes?

Hi, @darktron1337!

It would be helpful if you clarify the data model, i.e. relations between entities. For now, I can see several drawbacks.

Itā€™s recommended to add ItemPropertyChangeListener and check the precise property that has been changed:

projektExperienceDs.addItemPropertyChangeListener(e -> {
    if ("project".equals(e.getProperty())) {
        // do something
    }
});

In this case, you need to add a nested datasource for the skills attribute and clean a datasource instead of entity field.

Unfortunately, I canā€™t reproduce the problem without a demo project, so that I canā€™t give you any advice on how to solve the problem.

Regards,
Gleb

This is a simplified view on my Data structure:
image

Thank you for the data model diagram, but as I said above, unfortunately, I canā€™t reproduce the problem without a demo project.

Regards,
Gleb

Thanks for your help so far, sadly I wasnā€™t able to resolve the problem. I am also unable to send u my project because itā€™s not public.

Hi,

This why it is called a demo project :slight_smile: no one is interested in your real project. Create a new example project, take a similar domain (or just exchange domain names), put as little entities in it as possible, reproduce the bug.

If you can reproduce it, great - put it in here and we will try to figure out.
If you canā€™t reproduce - great. Try to identify what is different in your example. If you find something: repeat the process.

This has some major upsides:

  1. you will learn a lot. Isolating a problem is a very important skill to have. You will learn about the framework, about the patterns of your domain model, some internals of the framework and so on.

  2. You will increase the likelihood that you will get an answer. Think about it: this is free service. A lot of people donā€™t get payed to answer your question. Those who get, they can still pick the question that will give them a quick win. Since you probably donā€™t payed for the answer - if you do your very best to help the people to help you, so that you increase your chancesā€¦

  3. You created an abstract example that fulfils a community purpose. If the example is not mixed up with the domain you are in but instead with a domain everyone understand, you do the community a favor, because the likelihood that other people have a similar question.

  4. You are a good role model to other community members. When other people see you creating great questions, doing good examples etc. They will start mirroring your behavior. This leads to overall better examples, faster answers etc.

See also ŠžŃ‚Š²ŠµŃ‚Ń‹ Š½Š° Š²Š¾ŠæрŠ¾ŃŃ‹ - CUBA.Platform.

We look forward to your great example :wink:

Bye
Mario

3 Likes