Issue with navigation with URLs for new entities

Hello everyone,

I have a question about backward navigation. Let’s assume I want to create a new company, the URL for this will look something like this:
http://localhost:8080/company/new?.
Let us further assume I can create employees from the company detail view. So I will have a table of employees with a create button. For the creation, I will first save the dataContext, for the company to be saved in the database. Then I will navigate to the employee detail view and set an url parameter to give the companyId to the view of the employee, so it can be linked to the company.

When finished creating an employee, I hit “ok” which will save and close the detail view and return to the previous URL which in this case is the “new…” URL for companies. So a new company gets created. My expectation would be to return to the previously saved company.

I saw that StandardDetailView has a save method which refrehes the URL and sets the ID of the saved entity but that does not seem to work when dataContext.save() is called.

I want to inquire what the intended use of naviagtion in this scenario is.

Thanks for any hints!

Hello!

The navigation works as you described: it returns to the previous URL that contains /new. Since updating the URL is an asynchronous operation, the navigation is performed before the URL is updated.

The current workarounds exclude options involving navigation:

  • You can try to open Employee in dialog mode. Additionally, consider using the @Composition relation. It will enable saving employees only when the company is saved.
  • Consider using the Tabbed Application Mode add-on. It does not use routing and enables opening views as tabs within the main view.

Thank you Roman,
we will evaluate the solutions. Opening a dialog is difficult due to the complexity of the detail view but maybe 90% x 90% can work.
We loved the tabbed mode in JMix 1 but for JMix 2 we committed to the new paradigm of opening new screens and we are now too close to our first release version to change that, but it is on our list for further evaluation.

1 Like