jmix-framework / jmix

Jmix framework
https://www.jmix.io
Apache License 2.0
561 stars 121 forks source link

AfterNavigationHandler is invoked before the ReadyEvent handler #3419

Closed gorbunkov closed 2 months ago

gorbunkov commented 3 months ago

Environment

Jmix version: 2.3.0-RC1

Bug Description

Probably after changes made in https://github.com/jmix-framework/jmix/issues/3157, AfterNavigationHandler started being invoked before the ReadyEvent handler.

Suppose, you open the View2 view with the code like this:

        viewNavigators.view(this, View2.class)
                .withAfterNavigationHandler(view2AfterViewNavigationEvent -> {
                    View2 view2 = view2AfterViewNavigationEvent.getView();
                    view2.setData("aaa");
                })
                .navigate();

and the View2 looks as follows:

@Route(value = "View2", layout = MainView.class)
@ViewController("View2")
@ViewDescriptor("View2.xml")
public class View2 extends StandardView {
    private static final Logger log = LoggerFactory.getLogger(View2.class);

    @Subscribe
    public void onBeforeShow(final BeforeShowEvent event) {
        log.info("onBeforeShow");
    }

    @Subscribe
    public void onReady(final ReadyEvent event) {
        log.info("onReady");
    }

    public void setData(String aaa) {
        log.info("setData invoked");
    }
}

Current Behavior

The setData() method (from the withAfterNavigationHandler) is invoked before the onReady(...).

Expected Behavior

The code from withAfterNavigationHandler(...) must be invoked after all view lifecycle events, i.e. setData() must be invoked after the onReady()

Sample Project

untitled55.zip

konyashkina commented 2 months ago

Tested on Jmix version: 2.3.999-SNAPSHOT Jmix Studio plugin version: 2.3.SNAPSHOT6567-241 IntelliJ version: IntelliJ IDEA 2024.1.1