Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
BrowserFrame vs Label when it comes to URI Fragments
I recently started creating my first Vaadin application, and it includes a file browser so users can look through different corporate reports generated by another tool. The solution involves a tree on the left and a panel on the right displaying the file selected in the tree. HTML files, when clicked, get their contents displayed in a Label component on the right. So far, so good.
These files have links to other files, referenced by relative urls. To allow users to "drill down" into these report structures, I created a temp file where I rewrote the urls, pointing back to my application with a URI Fragment on the end used to locate the new file. This worked well, and development progressed.
Then I found that img src elements were not being displayed correctly. I rewrote those elements as well, copying their files on demand to a common area under my application. Again, things worked well, and development progressed.
Then I found that urls pointing to internal names <a href="#foo"> ... other stuff ... <a name="foo> absolutely did not work at all in Label components, but a simple test showed that they worked just fine in the BrowserFrame component (using FileResource).
However, all my url rewriting, adding uri fragments,does not work. Links clicked in the BrowserFrame component never made it back to my UriFragmentChangedListener (worked well with Label).
That is the main question. Following is just information on the urls as they get rewritten:
A link in the file, unaltered, looks like:
My application is at pkrouse-e6410:8080/FileBrowser/app. Using the Label component and rewriting the url, this link (when floating the mouse over it) says:
You can see the uri fragment on the end, and clicking this link works.
The same link in the same file, displayed in the BrowserFrame, looks the same when floating the mouse over it:
However, clicking this link will bring up the whole application again in the browserframe, and my fragmentchangedlinstener never fired.
If I do not rewrite the urls and look at that same link in the browserframe, the url looks like this:
But clicking that link does nothing at all.