RelatedEntities

Hi,

I’m trying to use a RelatedEntities component between the orders table (called Ven20) and the customer table (called Ana10).

From the tests I’m doing it seems that the customer code field in the orders table (called ven2010) and the customer code field
in the customer table (called ana1001) must have the same name … is it possible? What am I doing wrong?

Changing the property of the field name in the configuration RelatedEntities nothing happens.
The exception at runtime still remains the same:


java.lang.IllegalArgumentException: Property 'ana1001' not found in erp$Ven20
	at com.haulmont.chile.core.model.impl.MetaClassImpl.getPropertyNN(MetaClassImpl.java:107)
	at com.haulmont.cuba.gui.components.actions.RelatedAction.getCustomCondition(RelatedAction.java:272)
	at com.haulmont.cuba.gui.components.actions.RelatedAction.getManyToOneCondition(RelatedAction.java:241)
	at com.haulmont.cuba.gui.components.actions.RelatedAction.getOptimizedCondition(RelatedAction.java:200)
	at com.haulmont.cuba.gui.components.actions.RelatedAction.getRelatedEntitiesFilterXml(RelatedAction.java:182)
	at com.haulmont.cuba.gui.components.actions.RelatedAction.applyFilter(RelatedAction.java:165)
	at com.haulmont.cuba.gui.components.actions.RelatedAction.lambda$actionPerform$68(RelatedAction.java:133)
	at com.haulmont.cuba.gui.ComponentsHelper.__walkComponents(ComponentsHelper.java:265)
	at com.haulmont.cuba.gui.ComponentsHelper.walkComponents(ComponentsHelper.java:259)
	at com.haulmont.cuba.gui.components.actions.RelatedAction.actionPerform(RelatedAction.java:126)
	at com.haulmont.cuba.web.gui.components.WebPopupButton$PopupActionWrapper.actionPerform(WebPopupButton.java:342)
	at com.haulmont.cuba.web.gui.components.WebButton.performAction(WebButton.java:44)
	at com.haulmont.cuba.web.gui.components.WebButton.lambda$new$61446b05$1(WebButton.java:36)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)
	at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198)
	at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
	at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:1030)
	at com.vaadin.ui.Button.fireClick(Button.java:377)
	at com.haulmont.cuba.web.toolkit.ui.CubaButton.fireClick(CubaButton.java:54)
	at com.vaadin.ui.Button$1.click(Button.java:54)
	at sun.reflect.GeneratedMethodAccessor160.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:158)
	at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:118)
	at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:414)
	at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:274)
	at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:79)
	at com.haulmont.cuba.web.sys.CubaVaadinServletService$CubaUidlRequestHandler.lambda$synchronizedHandleRequest$112(CubaVaadinServletService.java:314)
	at com.haulmont.cuba.web.sys.CubaVaadinServletService.withUserSession(CubaVaadinServletService.java:196)
	at com.haulmont.cuba.web.sys.CubaVaadinServletService$CubaUidlRequestHandler.synchronizedHandleRequest(CubaVaadinServletService.java:314)
	at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
	at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1424)
	at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:369)
	at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:278)
	at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(CubaApplicationServlet.java:187)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at com.haulmont.cuba.web.sys.CubaHttpFilter.handleNotFiltered(CubaHttpFilter.java:108)
	at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:95)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)

Hi,

Could you please share the screen XML-descriptor?

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
















































Hi,

The following code shows how the RelatedEntities component could be configured.

Let me explain some aspects:

  1. The entity Order relates to Customer and Operator (both many_to_one). The corresponding attributes are named “customerLink” and “operatorLink”.
  2. The drop-down list of the RelatedEntitites component in UI is filled with attributes which are links to other entities.
  3. By adding a property block we can customize the list item: make it open the specified screen, with custom captions.
  4. And property name is the name of the entity attribute (“customerLink” and “operatorLink” in the code).

<dsContext>
        <groupDatasource id="ordersDs"
                         class="com.company.relatedentites.entity.Order"
                         view="order-view">
            <query>
                <![CDATA[select e from relatedentites$Order e]]>
            </query>
        </groupDatasource>
    </dsContext>
    <dialogMode height="600"
                width="800"></dialogMode>
    <layout expand="ordersTable"
            spacing="true">
        <filter id="filter"
                applyTo="ordersTable"
                datasource="ordersDs">
            <properties include=".*"></properties>
        </filter>

        <relatedEntities id="relatedEntities"
                         for="ordersTable"
                         openType="NEW_TAB">

            <property caption="CustomersScreen"
                      filterCaption="CustomersFilter"
                      name="customerLink"
                      screen="relatedentites$Customer.browse"></property>

            <property caption="OperatorsScreen"
                      filterCaption="OperatorsFilter"
                      name="operatorLink"
                      screen="relatedentites$Operator.browse"></property>

        </relatedEntities>

        <groupTable id="ordersTable"
                    width="100%">
            <actions>
                <action id="create"></action>
                <action id="edit"></action>
                <action id="remove"></action>
            </actions>
            <columns>
                <column id="data"/>
                <column id="costs"/>
                <column id="customerLink"/>
            </columns>

            <rows datasource="ordersDs"></rows>
            <rowsCount></rowsCount>
            <buttonsPanel id="buttonsPanel"
                          alwaysVisible="true">
                <button id="createBtn"
                        action="ordersTable.create"></button>
                <button id="editBtn"
                        action="ordersTable.edit"></button>
                <button id="removeBtn"
                        action="ordersTable.remove"></button>
            </buttonsPanel>
        </groupTable>
    </layout>

Rostislav thanks for your example.

I am attaching the source of the order entities (Ven20) and customer entity (Ana10) and the print screen of their association ManyToOne.

I put any value in the property field, ven2010, ana1001 … in the RelatedEntities configuration but the error remains the same.

IllegalArgumentException: Property ‘ana1001’ not found in erp $ Ven20

Excuse me if I still do not understand …

Thanks again.

related

Ven20.java (4.2K)

Ana10.java (2.4K)

Hi

I think, if to specify name=“ven2010” it should work:


<relatedEntities id="related"
                             caption="Related"
                             description="Related"
                             for="ven20sTable"
                             icon="icons/reports-print-row.png"
                             openType="NEW_TAB">
                <property caption="Cliente2"
                          filterCaption="Cliente2"
                          name="ven2010"
                          screen="erp$Ana10.browse"></property>
            </relatedEntities>

Hi,

sorry Rostislav, but before I write to you, I had already tried all the combinations.

So if I put ven2010 it does not work, if I put ana1001 does not work …

I also thought it was ven2010 the value to be put …

If you want, I can send you the entire project.

Hi,

At first, thank you for your patience. And sorry that I did not see before that the “Ana10” entity is BaseStringIdEntity, and the primary key has the name “ana1001”.

We have created a YouTrack issue, see the link on the right.
Due to the bug, RelatedAction could not work when the master and related entities have primary keys with different names.

As a workaround, you can rename the “ana1001” property to “id”, and the component will work.

Regards.

Hello,

I installed the 6.4.1 version, I found that you have solved this problem.

Many thanks.

Maurizio.

Hi Rostislav,

sorry but I have to reopen this old topic that I thought resolved, because I do not understand one thing.

If the fields in the two related tables do not have the same name, where do I specify the relationship?

Currently after fix from 6.4.1, the form of the related entity opens without errors but without any filter applied.

In the example I did between order (Ven20) and customer (Ana10), whether i put ven2010, or put ana1001 does not change anything … the table opens and show all the records, not only the customer related.

Thank you.

Maurizio.

:ticket: See the following issue in our bug tracker:

https://youtrack.cuba-platform.com/issue/PL-8420