Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vaadin 14: Trying to open Page in background from Dialog while keeping the dialog opened

I have a dialogue box that is:

  1. Draggable
  2. Modal

Requirement:

I have a requirement where I don't need to close my dialogue and have to load the different pages in the background on the selection of data from the grid that is on Dialogue.

What did I do: I know how to open the page in the background with the help of a de-attached listener.

vehicleInfoPopUpView.addDetachListener(e -> {

        UI.getCurrent().navigate(AssignmentPageContainer.class,
            String.valueOf(vehicleInfoPopUpView.getCanFileNumber()));
    });

The above code (in the parent page) loads/opens a new page but to do this I have to close my dialogue box (which I don't have to do, I have to keep the dialogue box open).

I cannot find any resource that tells me How to load/open a new page in the background from the dialogue box without closing it

Any small help! Thanks for the help in advance.

like image 445
Prashant Kumar Avatar asked Jan 21 '26 22:01

Prashant Kumar


1 Answers

First of all: Don't.

Keeping a modal dialog open whilst navigating to a different page/route makes no UX sense. A modal window means you cannot interact with the background.

Just call UI.getCurrent().navigate(AssignmentPageContainer.class) directly (outside of detach listener) to open the view based on the selection. The user will open the dialog again himself, if he will want to. You can trigger this on some button click.


Secondly, as a workaround you could store the state of the dialog in a @UIScoped service and open & reinitialize the dialog f.e. in the afterNavigation method.

like image 123
Hawk Avatar answered Jan 24 '26 18:01

Hawk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!