ViewNavigators pass parameter without using Route/Query

Hello! I have a question regarding parameter passing in Jmix 2.3 with ViewNavigator.

Is there a plan to support a fluent interface for directly passing parameters to a view via ViewNavigator, similar to how parameters are passed in DialogWindow, without relying on query or route parameters? This would streamline parameter management and avoid the need for route/query-based passing in cases where we want to keep parameters internal or more secure.

Thank you!

Hello!
Thank you for the question.
Could you please provide a use case for this feature?

Hello, thank you for the response!

Here’s a use case, similar to what was available in CUBA with ScreenBuilders:

In our app, we often need to pass entities or sensitive data between views without exposing them in the URL. For example, when navigating from a list to a detail view, we might want to securely pass an entire entity without relying on query or route parameters.

In CUBA, we used ScreenBuilders to set parameters directly, like this:

EditScreen screen = screenBuilders.editor(entityTable)
                                .withScreenClass(EditScreen.class)
                                .newEntity()
                                .build();
screen.setAnotherEntity(e.getScreen().getAnotherEntity());
screen.show;

A similar fluent interface in ViewNavigator would simplify parameter handling in Jmix FlowUI.

Thank you for considering this!

1 Like

Currently, I’m passing parameters from one View to another by overriding the afterNavigation method in EntityDetailView to capture parameters passed from EntityListView, as shown below:

EntityListView.java

viewNavigators.detailView(this, Entity.class)
    .withViewClass(EntityDetailView.class)
    .withBackwardNavigation(true)
    .withAfterNavigationHandler(afterViewNavigationEvent -> {
        // Is only invoked after all lifecycle events of a view finished
        EntityDetailView view = afterViewNavigationEvent.getView();
        view.setFormMode(ActionType.INSERT.getId());
        view.setAnotherEntity(anotherEntity);
        log.info("AfterViewNavigationEvent finished.");
    })
    .newEntity()
    .navigate();

EntityDetailView.java

private String formMode;
private AnotherEntity anotherEntity;

public void setFormMode(String formMode) {
    this.formMode = formMode;
}

public void setAnotherEntity(AnotherEntity anotherEntity) {
    this.anotherEntity = anotherEntity;
}

@Override
public void afterNavigation(AfterNavigationEvent event) {
    super.afterNavigation(event);
    log.info("Another entity: {}", anotherEntity);
    log.info("FormMode: {}", formMode);

    if (formMode.equals(ActionType.INSERT.getId())) {
        initNewEntity(anotherEntity);
    } else {
        initEditedEntity(anotherEntity);
    }
}

I’m not certain if this is the best approach, so feel free to suggest any improvements.

Hello, you are going in the right direction.
Here is the example of usage withAfterNavigationHandler()

Yes, I use the withAfterNavigationHandler() in combination with afterNavigation(). This approach requires moving the initNewEntity() logic into afterNavigation(), whereas in CUBA, we could set parameters directly and perform actions before or during onAfterShow() or onBeforeShow(). This added flexibility in CUBA allowed for cleaner parameter passing and initialization steps prior to view rendering.

Hi,

Due to Vaadin limitations, we cannot get access to a view instance during navigation, only after it.

Regards,
Gleb

1 Like