Creating an entity goes to the default entity details page

Hi,
I have an entity called TrxHead and 2 list pages displaying the records in the table. The pages are Trx Head List and Self Billed Transaction List. When i click the Create button on Self Billed Transaction List, I was redirected to Trx Head Details instead of Self billed Transaction Detail. Why is that and how to ensure the correct detail page is called?
This is the relevant code for each page, please lmk if any details are needed.
Self Billed Transaction List

@Route(value = "selfBillingTransactions", layout = MainView.class)
@ViewController("SelfBillingTransaction.list")
@ViewDescriptor("self-billing-transaction-list-view.xml")
@LookupComponent("trxHeadsDataGrid")
@DialogMode(width = "64em")
public class SelfBillingTransactionListView extends StandardListView<TrxHead> {

}

Self Billed Transaction Details

@Route(value = "selfBillingTransaction/:id", layout = MainView.class)
@ViewController("SelfBillingTransaction.detail")
@ViewDescriptor("self-billing-transaction-detail-view.xml")
@EditedEntityContainer("trxHeadDc")
public class SelfBillingTransactionDetailView extends StandardDetailView<TrxHead> {
}

Trx Head Detail

@Route(value = "trxHead/:id", layout = MainView.class)
@ViewController("TrxHead.detail")
@ViewDescriptor("trx-head-detail-view.xml")
@EditedEntityContainer("trxHeadDc")
public class TrxHeadDetailView extends StandardDetailView<TrxHead> {
}

Thank you.

Hello!

It is expected behavior, because default navigation mechanism in Create/Edit actions tries to infer the appropriate detail view. See Opening Views :: Jmix Documentation.

When navigating to a detail view or opening it in a dialog window, the framework selects a view in the following order:

  1. A view annotated with @PrimaryDetailView(SomeEntity.class).
  2. A view with SomeEntity.detail id.

In your case, the TrxHead entity name does not match with SelfBillingTransaction name, so the Trx Head Details is opened.

You can simply fix it by specifying the ID or controller class in actions. For instance:

<action id="create" type="list_create">
    <properties>
        <property name="viewClass" value="com.demo.view.trxhead.SelfBillingTransactionDetailView"/>
    </properties>
</action>

Or specify a viewId the same way.

Thank you!