A single combined Edit/Browse screen for inheritance entities with FieldGroups for each entity type

Hi everyone,

I’ve been messing about trying to create a Combined Browse/Edit screen for use with Multiple Inheritance Entities.

For example:

I have a Person that has relationships with other people. Each relationship has different data requirements. So I have the following entities

  • Person
  • Relationship (JOINED inheritance strategy defined)

Then I have the following Entities that inherit from Relationship.

  • SpouseRelationship
  • ChildRelationship
  • BasicRelationship

So ideally I wanted a Combined Browse/Edit screen to show a basic list of Relationships and the ability to create and edit the more detailed Inherited Relationship Entities. Like this image shows.

image

I didn’t find anything in CUBA that did exactly what I needed so I took the current EntityCombinedScreen class and created a EntityInheritanceCombinedScreen

So my new screen has a PopupButton for the create action as shown here.

image

I have multiple FieldGroups based on different Datasources and each FieldGroup is in a Tab. The EntityInheritanceCombinedScreen takes care of switching the Tabs to show the correct FieldGroup for the Selected Item or the New Item. as shown here.

image

image

I’ve only being using CUBA for a couple of months so I don’t claim that this is exactly how it should be done or if if it should be done. It does all seems to hang together pretty well so I think that is a good sign.

I’ve added my project that I was trying to work this out in. If anyone does have a look and spots issues can they share the issue and fix if you have one.

SelfReferencing.zip (570.5 KB)

EDIT:
Project zip as created by Gradle zipProject

SelfReferencing.zip (91.2 KB)

5 Likes

Hi John,
Thank you for this example!

Just one comment: please use zipProject Gradle task, it excludes IDE project files (which have your local settings) and includes HSQL database which is helpful for demo purposes.

1 Like

@knstvk

Could we get the zipProject Gradle task added to CUBA Studio in the Build or Run menus?

That’s a good idea. Created issue: https://youtrack.cuba-platform.com/issue/STUDIO-4534

BTW, right now you can execute Gradle tasks from Studio, just press Alt+/ (Option+/) and start entering the task name.

I didn’t know that @knstvk thanks