I have an app which relies on several submodules.
In one of the base submodules I have a class called Document. In the App project I override the class to include a reference to another entity from a different submodule. So far so good.
The point is that when creating a screeneditor for the extended Document version ExtDocument I seem to do it correctly but when clicking on Create button from the browser screen I get a metaClass error prompting that the metaClass is incorrect for the given InstanceContainer.
Error:
DevelopmentException: Invalid item's metaClass 'central_Document'
container: InstanceContainerImpl{entity=sofiapp_ExtDocument, view=com.sofia.app.entity.ExtDocument/}
metaClass: central_Document
Here the files:
document-edit.xml (base class)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://jmix.io/schema/ui/window"
caption="msg://documentEdit.caption"
>
<data>
<instance id="documentDc"
class="com.sofia.central.entity.Document">
<fetchPlan extends="_base">
<property name="supplier" fetchPlan="_base"/>
<property name="additionalConcepts" fetchPlan="_base"/>
</fetchPlan>
<loader/>
<collection id="additionalConceptsDc" property="additionalConcepts" />
<instance id="attachmentCollectionDc" property="attachmentCollection"/>
</instance>
</data>
<facets>
<dataLoadCoordinator auto="true"/>
<screenSettings id="settingsFacet" auto="true"/>
</facets>
<actions>
<action id="windowCommitAndClose" caption="msg:///actions.Ok"
icon="EDITOR_OK"
primary="true"
shortcut="${COMMIT_SHORTCUT}"/>
<action id="windowClose"
caption="msg:///actions.Close"
icon="EDITOR_CANCEL"/>
</actions>
<dialogMode height="600"
width="800"/>
<layout spacing="true" expand="main">
<scrollBox id="main">
<split id="submain" width="100%" height="100%" orientation="horizontal">
<vbox spacing="true" >
<comboBox dataContainer="documentDc" id="typeField" property="type" caption="Document Type"/>
<entityPicker caption="Supplier" dataContainer="documentDc" id="supplierField" property="supplier" captionProperty="person.completeName">
<actions>
<action id="entityLookup" type="entity_lookup"/>
<action id="entityClear" type="entity_clear"/>
</actions>
</entityPicker>
<textField caption="Document #" dataContainer="documentDc" id="documentNumberField" property="documentNumber"/>
<dateField caption="Issue Date" dataContainer="documentDc" id="issueDateField" property="issueDate"/>
<textArea width="100%" caption="Description" dataContainer="documentDc" id="descriptionField" property="description" rows="5"/>
<textField caption="Total Base" dataContainer="documentDc" id="totalBaseField" property="totalBase"/>
<hbox width="100%" spacing="true" id="hbxtables">
<table caption="Additional Concepts" dataContainer="additionalConceptsDc" id="tblAdditionalConcepts" width="100%" height="250px">
<actions>
<action id="createAC" type="create"></action>
<action id="editAC" type="edit"></action>
<action id="removeAC" type="remove"></action>
</actions>
<buttonsPanel>
<button id="btnCreateAC" action="tblAdditionalConcepts.createAC"/>
<button id="btnEditAC" action="tblAdditionalConcepts.editAC"/>
<button id="btnRemoveAC" action="tblAdditionalConcepts.removeAC"/>
</buttonsPanel>
<columns>
<column id="additionalConceptType" caption="Type"></column>
<column id="base"></column>
<column id="percentage" caption="%"></column>
<column id="quote"></column>
</columns>
</table>
</hbox>
<textField caption="Total Amount" dataContainer="documentDc" id="totalAfterAdditionalConceptsField" property="totalAfterAdditionalConcepts"/>
<checkBox caption="Ommit at Payment Control" dataContainer="documentDc" id="ommitDocumentAtPaymentControlField" property="ommitDocumentAtPaymentControl"/>
</vbox>
<!-- browser element part to display the document scan on the right hand side -->
<browserFrame width="100%" height="500px" id="browserPreview">
</browserFrame>
</split>
<fragment id="attachmentCollectionFragment" height="400px" screen="AttachmentCollectionFragment"/>
</scrollBox>
<hbox id="editActions" spacing="true">
<button id="commitAndCloseBtn" action="windowCommitAndClose"/>
<button id="closeBtn" action="windowClose"/>
</hbox>
</layout>
</window>
extending class ExtDocument descriptor extydocument-edit.xml:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://jmix.io/schema/ui/window"
caption="msg://com.sofia.central.screen/documentEdit.caption"
extends="com/sofia/central/screen/document-edit.xml">
<data>
<instance id="documentDc"
class="com.sofia.app.entity.ExtDocument">
<fetchPlan extends="_base">
<property name="supplier" fetchPlan="_base"/>
<property name="additionalConcepts" fetchPlan="_base"/>
<property name="allocations" fetchPlan="_base"/>
</fetchPlan>
<loader/>
<collection id="additionalConceptsDc" property="additionalConcepts" />
<instance id="attachmentCollectionDc" property="attachmentCollection"/>
<collection id="allocationsDc" property="allocations"/>
</instance>
</data>
<layout>
<scrollBox id="main">
<split id="submain">
<vbox>
<table caption="Allocations" id="tblAllocations" width="100%" height="250px" dataContainer="allocationsDc">
<actions>
<action id="createAll" type="create"></action>
<action id="editAll" type="edit"></action>
<action id="removeAll" type="remove"></action>
</actions>
<buttonsPanel>
<button id="btnCreateAll" action="tblAllocations.createAll"/>
<button id="btnEditAll" action="tblAllocations.editAll"/>
<button id="btnRemoveAll" action="tblAllocations.removeAll"/>
</buttonsPanel>
<columns>
<column id="extCycle.unit.fullDescriptiveName"></column>
<column id="percent"/>
<column id="amount"/>
<column id="moreInfo"/>
</columns>
</table>
</vbox>
</split>
</scrollBox>
</layout>
</window>
This is the first time I try to implement extending logic with an architecture of submodules. But I am following strictly the rules at:
https://docs.jmix.io/jmix/modularity/extension.html
But this is getting in the way.
As a workaround I have tried to extend aswell the browser screen. But got other kind of issues.
The difference between the two classes is the addition of a collection of class Allocation, in the member allocations of the extending class.
Don’t know how to hint JMIX to the extending class metaclass. I presume that the metaclass is correct, however the instance container is not accepting it.
Any ideas?
Thanks for your inisghts and regards.
Carlos.