Extending Tenancy UI

Hi all,
I have followed the documentation (Extending Functionality :: Jmix Documentation) to extend the tenant data model and its UI.

I have extended the tenant data model following the documentation. It is now called OrgRegistration.

I have also extended the tenant UI- ExtTenantBrowse and ExtTenantEdit

See below the extended UI- ExtTenantBrowse:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://jmix.io/schema/ui/window"
        caption="msg://io.jmix.multitenancyui.screen.tenant/tenantBrowse.caption"
        extends="io/jmix/multitenancyui/screen/tenant/tenant-browse.xml"
        xmlns:ext="http://jmix.io/schema/ui/window-ext">
    <data>
        <collection id="orgRegistrationsDc" class="com.modula.sapb1portalmgt.entity.misc.OrgRegistration">
            <fetchPlan extends="_base"/>
            <loader id="orgRegistrationsDl">
                <query>
                    <![CDATA[select e from spm_OrgRegistration e]]>
                </query>
            </loader>
        </collection>
    </data>
    <layout>
        <groupTable id="tenantsTable">
            <columns>
                <column id="firstName"/>
                <column id="lastName"/>
            </columns>
        </groupTable>
    </layout>
</window>

ExtTenantEdit:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://jmix.io/schema/ui/window" caption="msg://io.jmix.multitenancyui.screen.tenant/tenantEdit.caption"
        xmlns:ext="http://jmix.io/schema/ui/window-ext"
        extends="io/jmix/multitenancyui/screen/tenant/tenant-edit.xml">
    <layout>
        <form id="tenantForm" dataContainer="tenantDc">
            <column width="350px">
                <textField id="firstNameField" property="firstName" ext:index="0"/>
                <textField id="lastNameField" property="lastName" ext:index="1"/>
            </column>
        </form>
    </layout>
</window>

The problem I have with the ExtTenantBrowse is that I am getting this error:

IllegalStateException: Cannot get unfetched attribute [firstName] from detached object com.modula.sapb1portalmgt.entity.misc.OrgRegistration-a37a9746-c6db-3893-9098-049c8b1f9e51 [detached].

I am not able to retrieve firstName and lastName. These are the fields added to the extended tenant data model.

image

Another problem I have with ExtTenantEdit is that the firstName & lastName fields are displayed below the base entity. See below.

How can these fields be displayed immediately below the tenant name?

image

Thanks

Obviously, I do not know your requirements.

But having a few years of XP building apps with Cuba/JMIX, I would recommend avoiding the extension mechanisms altogether unless really necessary. It should be your last resort.

The tenant entity and related screens are so simple that it will be a lot simpler just to define your own variants.

There are basically 2 possibilities here:

  1. Inheritance - Subclass the tenant entity and create your own screens.
  2. Composition - Create your own entities and have a relationship with the jmix entities. This way you can reuse the existing tenant browse and edit screens.

Hi Tom,
Thanks for your effort. What I want do is simple- I just want to extend the Tenant model which I have done successfully. The next step is to extend the UI- this is where I am having the error message pop up.

IllegalStateException: Cannot get unfetched attribute [firstName] from detached object com.modula.sapb1portalmgt.entity.misc.OrgRegistration-a37a9746-c6db-3893-9098-049c8b1f9e51 [detached].

image

Hope I make my requirement clearer now.

Thanks

@olumideo I understand what you are doing.

My point is that for an entity with 2 fields (Tenant) I would define my own screens (and probably entities) instead of trying to rely on extension mechanisms.

This extension stuff just complexifies stuff through some magic rather then just defining it yourself.

I can’t find a post or documentation about it anymore, but I seem to remember that this once was (probably forum post) documented in Cuba saying something like “If you can avoid extending framework entities do so, it makes things easier.”

Hi Tom,
Thanks for your assistance. I later figured out the solution. The reason I was having the error was that I did not add property dataContainer to my groupTable. All is well now.

  <groupTable id="tenantsTable" dataContainer="orgRegistrationsDc">
            <columns>
                <column id="firstName"/>
                <column id="lastName"/>
                <column id="website"/>
            </columns>
        </groupTable>
1 Like