How to mimic viewConfigurer in ui test to call method on a view before AfterViewNavigationEvent

I have a detail view with an entityComboBox. I pass in items to populate that combox via a viewConfigurer from a list view.

    @Install(to = "redundancyRulesDataGrid.createAction", subject = "viewConfigurer")
    private void redundancyRulesDataGridCreateActionViewConfigurer(InfraStructureRedundancyRuleDetailView detailView) {
        detailView.setInfraStructureLevelCandidates(levelsDc.getItems());
    }

Then, in the detailView. I pick up those items and set them to the appropriate datacontainer that backs the combobox.

    @Setter
    private List<InfrastructureLevel> candidateParentLevels;

    @Subscribe
    public void onBeforeShow(final BeforeShowEvent event) {
        candidateParentsDc.setItems(doSomethingWith(candidateParentLevels));
    }

This works fine. But I can not mimick this in a unit test using viewnavigators. The candidateParentLevels is null and the screen depends on it.

            viewNavigators.detailView(UiTestUtils.getCurrentView(), InfrastructureLevel.class)
                .newEntity()
                .withViewClass(TARGET_VIEW)
                .withAfterNavigationHandler(event -> {
                    InfrastructureLevelDetailView view = event.getView();
                    view.setCandidateParentLevels(new ArrayList<>());
                })
                .navigate());

I tried using a ReadyEvent instead, but that still gives the same problem. The readyEvent is still fired before the AfterViewNavigationEvent

I could fall back to using viewNavigators and custom create action instead of using the ViewConfigurer. But the viewConfigurer is much cleaner, it also kinda beats the whole point of the viewConfigurer.

Hello!

Yes, the afterNavigationHandler and viewConfigurer are not equivalent.

The after navigation handler is called after all lifecycle events of view  as JavaDoc says. The general way to pass parameters to navigated view  is to use query parameters. However, in UI integration tests it is not supported.
Did you try to change the setter method logic? For instance, set items directly to data container; does it suit you?