Creating multiple entities in one edit window

Hi!

I am trying to create multiple instances of a entity in one screen. I am writing a employee management software. Every employee has multiple skills. Employees and skills are linked with a UserSkillLink. The UserSkillLink also stores additional information like date and skill level…

I have a edit screen for my employees. In this edit screen I have a inline editable table with the already existent UserSkillLinks. I now want to add multiple new UserSkillLinks to the Table. How can I achieve this?

At the moment my UserSkillLink Edit screen only allows to add one UserSkillLink. The UserSkillLink Edit screen has a picker field to pick the skill. The picker field opens a skill browse window which has multiselect enabled. But when I press OK only one Skill is put to the pickerField in the UserSkillLink Edit window.

Code:

<window xmlns="http://schemas.haulmont.com/cuba/window.xsd"
        caption="msg://editCaption"
        class="de.bredexsw.superskill.gui.user.UserEdit"
        datasource="userDs"
        messagesPack="de.bredexsw.superskill.gui.user">
    <dsContext>
        <datasource id="userDs"
                    class="de.bredexsw.superskill.entity.User"
                    view="user-with-relations">
            <collectionDatasource id="skillDs"
                                  property="userskilllink"/>
        </datasource>
    </dsContext>

	<tab id="skillsTab"
                     caption="msg://Skills"
                     expand="skillTable"
                     margin="true,false,true,false"
                     spacing="true">
                    <buttonsPanel id="skillsButtons">
                        <button action="skillTable.create"/>
                        <button action="skillTable.remove"/>
                    </buttonsPanel>
                    <table id="skillTable"
                           width="100%"
                           editable="true">
                        <actions>
                            <action id="create"/>
                            <action id="remove"/>
                        </actions>
                        <columns>
                            <column id="skill.name"/>
                            <column id="skill.skillcategory.name"/>
                            <column id="level"
                                    editable="true"/>
                            <column id="tested"
                                    editable="true"/>
                            <column id="used"
                                    editable="true"/>
                        </columns>
                        <rows datasource="skillDs"/>
                    </table>
                </tab>

        <frame screen="editWindowActions"/>
    </layout>
</window>

Hi!
I doesn’t actually get all data model what you have but i think you should look closer to OpenLookup method.
Some scratch (doesn’t tested):

public void onAddSkills(){
     this.openLookup("UserSkill.brows",        
        skill -> {                        
            createSkillLink(skill);       
        },                                
        WindowManager.OpenType.DIALOG);  
} 
/* Now we can create new skill for employee */
protected void createSkillLink(UserSkill skill){                      
    UserSkillLink newSkillLink = metadata.create(UserSkillLink.class);
    newSkillLink.setSkill(skill);                                     
    newSkillLink.setUser(this.getItem());                             
    /*...*/                                                           
    skillDs.addItem(newSkillLink);                                    
}