How to access BrowserFrame content


I have a quite complicated situation with two problems not tied to vaadin (so I skip to explain that) and in my workaround attempt I am using BrowserFrame component pointing it to an ExternalResource


        restFrame = new BrowserFrame("", new ExternalResource("about:blank"));

        ExternalResource restCall = "http://someintraneturl.somedomain";
        // Get displayed browser content

My problem now is: I need to access the content in that BrowserFrame. I tried with restFrame.getData() which always is null. I did not found anything else that offers an access to the actual displayed content of the BrowserFrame. I can get the URL via ((ExternalResource) restFrame.getSource()).getURL() but not the content itself.

Shouldn’t there be a chance to get to the displayed content - which in my case is a json string.

For the case you ask: I cannot use the url and get the content myself as the result is different when I pull the result of the url from the server-side. And I know about the option

but for the reasons I mentioned above and I do not want to annoy you with, I cannot use this approach.

In the meantime I tried several approaches using my own URL to some sort of “proxy” where I do my own javascript performing the needed REST request and afterwards updating the current URL of the iframe. The same origin policy of the browser does limit my options unfortunately.

Basically the background of my problem is that I need to do a REST request from the client to a separate site retrieving a session id which I need to reuse from my server-side Vaadin - so I need to do the request on the client side and then transfer the session id somehow to the server.

As I did not have any chance to access the BrowserFrame content, I thought, if I change the url of the BrowserFrame adding the session id as url parameter I could read the current url from the Vaadin server part, but unfortunately

((ExternalResource) parent.getRestFrame().getSource()).getURL() always returns the original url which I have set on init. Browsing in the BrowserFrame does not seem to change the url in Vaadin.

From within the javascript running in the browserFrame I tried changing the URL using

window.src = newUrl; window.location.assign(newUrl); Neither of those attempts failed although after window.location.assign(newUrl) to the same url again + parameter showed the new url when requerying window.location.href - which reflects the new url. With Firefox inspector I could see that the iframe src attribute does not change to reflect the new url. Maybe this is the problem here.

If there is no way to get the BrowserFrame content, is there at least a way to get the current URL that is displayed in the BrowserFrame - which of course may change when the user surfs within that iframe or if some javascript changes the address?