Events fired when screens.showFromNavigation(screen) is used

Hello,

I have got an application that has a search list page and and a detail page for the items form the list. The items within the search list page are rendered by fragments. The app allows to select an item from the list and to jump into the detail page and vice versa. For user convenience I want to display the result page in the same way as it was shown before the user jumped to the detail page.

So it is needed to bring the last selected item into focus when the user jumps back. Therefor I use a button and the function:

screens.showFromNavigation(beforeScreen);

To be able to focus the last selected element I need an event that is fired within the page when it will be shown again. I tested onBeforeShow, onAfterShow events, but these events are not fired. Is there another way to get noticed when the page is shown again?

The window mode is SINGLE.

Thanks for any tipps

Hi,

I guess that you open the detail screen programmatically, so the easiest solution is to subscribe to the close event of the screen that you open, e.g.:

@Subscribe("btn")
public void onBtnClick(Button.ClickEvent event) {
    screenBuilders.screen(this)
            .withScreenClass(TestScreen.class)
            .withAfterCloseListener(screenCloseEvent ->
                    notifications.create()
                            .withCaption("Screen closed")
                            .show())
            .show();
}

Gleb

1 Like