Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Refreshing a native window opens the main application instead
I am trying to open a PDF in a new browser window when a button is pressed.
So far I got this working by implementing the native window example from the sampler and then just opening my resource (which contains the PDF) in that new window. That way I get a new browser window in which Adobe Reader opens and displays the PDF.
The problem is that certain browsers like Firefox offer a back button on the native window, which does not lead to the window I created, but the current instance of the main application itself! If this happens, the "main" browser window which contains the application gets out of sync.
This is partly reproducable in the sampler, just click the native window example and refresh the newly opened subwindow. It will refresh to show an instance of the sampler instead of the label that it should display. The same happens for me, the window I open gets displayed for a split second before the PDF is loaded, but if I go back afterwards I get my app instead, desyncing the first browserwindow.
Is there any way around this, or do I have to try a different approach?
This is how my code looks like right now:
public void openResourceInWindow(Resource resource) {
Window window = new NativeWindow();
MyApplication.getCurrent().addWindow(window);
getWindow().open(new ExternalResource(window.getURL()), "_blank");
window.open(resource);
}
This method is called in the main window of my application, resource is a StreamResource containing a PDF as a ByteArrayOutputStream.