Hi,
i have encountered the following situation in studio 2.2.2 and i think it is a bug if not multiple. Here’s the situation:
I created an Entity Customer with attributes “name: string”, “address: Address”, “deliveryAddress: Address”. The Address is an embedded entity with the attributes “street: string”, “city: string”.
I create a view for the customer containing both addresses and their attributes (“customer-view”). When i now generate screens for the customer with the “customer-view”, it creates the following “customer-edit.xml”:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://schemas.haulmont.com/cuba/window.xsd"
caption="msg://editCaption"
class="com.company.exampleembedded.web.customer.CustomerEdit"
datasource="customerDs"
focusComponent="fieldGroup"
messagesPack="com.company.exampleembedded.web.customer">
<dsContext>
<datasource id="customerDs"
class="com.company.exampleembedded.entity.Customer"
view="customer-view">
<datasource id="addressDs"
property="address"/>
<datasource id="deliveryAddressDs"
property="deliveryAddress"/>
</datasource>
</dsContext>
<layout expand="windowActions"
spacing="true">
<fieldGroup id="fieldGroup"
datasource="customerDs">
<column width="250px">
<field id="name"/>
<field id="street"
datasource="deliveryAddressDs"/>
<field id="city"
datasource="deliveryAddressDs"/>
</column>
</fieldGroup>
<frame id="windowActions"
screen="editWindowActions"/>
</layout>
</window>
Basically the attribute “address” is missing. Nevertheless, the “addressDs” gets created. When changing the implementation to also include the “address” attributes like this:
<fieldGroup id="fieldGroup"
datasource="customerDs">
<column width="250px">
<field id="name"/>
<field id="street"
datasource="deliveryAddressDs"/>
<field id="city"
datasource="deliveryAddressDs"/>
<field id="street"
datasource="addressDs"/>
<field id="city"
datasource="addressDs"/>
</column>
</fieldGroup>
i get a runtime exception when open the customer editor:
GuiDevelopmentException: FieldGroup column contains duplicate fields 'street'.
Frame ID: exampleembedded$Customer.edit
XML descriptor: com/company/exampleembedded/web/customer/customer-edit.xml
FieldGroup ID: fieldGroup
Which is reasonable.
I ended up with the following implementation:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://schemas.haulmont.com/cuba/window.xsd"
caption="msg://editCaption"
class="com.company.exampleembedded.web.customer.CustomerEdit"
datasource="customerDs"
focusComponent="fieldGroup"
messagesPack="com.company.exampleembedded.web.customer">
<dsContext>
<datasource id="customerDs"
class="com.company.exampleembedded.entity.Customer"
view="customer-view" />
</dsContext>
<layout expand="windowActions"
spacing="true">
<fieldGroup id="fieldGroup"
datasource="customerDs">
<column width="250px">
<field id="name"/>
<field id="deliveryAddress.street" caption="Delivery Address Street"/>
<field id="deliveryAddress.city" caption="Delivery Address City"/>
<field id="address.street" caption="Address Street"/>
<field id="address.city" caption="Address Street"/>
</column>
</fieldGroup>
<frame id="windowActions"
screen="editWindowActions"/>
</layout>
</window>
Initially i created only the address attribute on the customer and generated the screens - which worked fine. After i added the “deliveryAddress” attribute to the customer and studio wanted to adjust the existing editor screen - instead of adding the attribute it changed the super class of the editor to “AbstractWindow” which lead to the situation that after a click on edit i got an exception saying i count not cast CustomerEdit to AbstractEditor.
Attached you’ll find the example project at the state with the wrong generated edit screen.
Perhaps you might take a look. That would be great!
Bye,
Mario
example-embedded.zip (80.9K)