How can I close Browser Screen instantly, when returning from Edit Screen?

Hello,
using JMix 1.5,
having browser and edit screen (not master-detail) for a certain entity,
I want a user to only add data.

So when he clicks the menu item,
browser screen opens,
then with createBtn.click() in onAfterShow I open the edit screen.
Now,
when the user leaves the edit screen (with or without commit) the browser screen should close itself.

Thanks for ideas,

HP

When the user clicks either cancel or ok, you can publish an event, and the browse screen has an event listener that will close it.
But what if the user wants to create more then one record?

Hi, Thank you. Are there any docs available? ChatGPT prompts curious things about events in Jmix…

I found:
https://docs.jmix.io/1.x/jmix/1.5/ui/screens/screen-fragment-events.html#listening-to-host-screen-events

is this representative?

In the line:

public Subscription addChangeListener(Consumer<CountryChangeEvent> listener) {
    return getEventHub().subscribe(CountryChangeEvent.class, listener); 
}

getEventHub() isn’t available…!

Thanks for help and support in advance,

br
HP

I just realized, you don’t need to open the browse screen at all, you just want to directly insert a record.

So just edit the Main Menu and add your edit screen, just like the browse screen is already there.

        <item screen="ExampleEntity.edit"
              caption= "Edit example entity"/>

You can keep your browse screen too if needed (and assign appropriate access), just remove that onAfterShow handler.

In your example above, you open the browse screen, and directly after the edit screen, but a user can navigate back to the browser screen with breadcrumbs …

Kind regards,
Mladen

Thanks, will return here soon… :wink:

Perhaps it’s better to invoke a bean that opens the edit screen, as described at MenuConfig :: Jmix Documentation

The docs give an example with programmatic opening of a browse screen, but it’s the same for editor, you just need to provide an entity instance to edit.

1 Like