Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
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")); restFrame.setId("restBrowser"); restFrame.setSizeFull(); restFrame.setImmediate(true); restFrame.setVisible(false); [...] ExternalResource restCall = "http://someintraneturl.somedomain"; restFrame.setSource(restCall); // 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.
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
always returns the original url which I have set on init. Browsing in the BrowserFrame does not seem to change the url in Vaadin.
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.