In the context of a multi-page application i'm trying to perfect a strategy for navigating from a page to the others.
I'm finding it difficult because there is not an obvious solution and combining the different approaches is not always viable because of behaviours that i didn't expect.
I found different problems but it would be too much material for a single question, so I decided to dedicate a question for each single problem.
This is dedicated to the navigate via view parameter that doesn't work with the browser's refresh button.
I'm talking of the code:
It seems to me that it should be kept apart from the others (page and url) because it's completely different.
When system.perspective.navigate is called with page or url parameter it causes the browser to change its address and reload from the new URL; in this case there should be a page configuration that 'connects' the url to the view.
Instead, when the parameter 'view' is used, the browser is not involved in the operation; it's a server-only functionality in which the specified view is rendered in the current URL. As a consequence, this way does not require a page configuration to 'connect' (or 'publish') the view to an url.
What is the use case for this navigation strategy? I thought of this: I have a page that can show a certain document but requires the user to look up in a list which one they want to open.
I can publish a single URL and just switch between the document view and the lookup (or index) view as needed.
Unfortunately, after implementing this solution i discovered that hitting the refresh button of the browser, the view goes back to the initial view.
How to reproduce the problem
I created a main view and a secondary view; only the main view has an url associated in Page configuration.
The main view contains only a button. The button's onActionPerformed navigates to "SecondaryView" using the view parameter:
Additionaly i passed to the view a parameter with the current timestamp to see if it gets refreshed correctly.
The secondary view has the parameter myViewParam and shows it in a bound label.
Now in the browser we see this:
When you click the button the server renders the "SecondaryView" to the same url:
The problem: if at this point you click refresh in the browser it goes back to the MainView.
I couldn't find any reference to this behavior in the docs and if in some cases it may be beneficial to a certain specific applications, in general it seems to introduce a degree of instability at the interface level that has to be fixed with different workarounds. (For example, I tried to call system.perspective.navigate from the onStartup event of the view if certain conditions are not met. It works but again it does not 'seem right').
Most of all it seems like this is not the preferred navigation strategy in perspective.
Any idea about this? Should be avoided? Has some specific use cases that I couldn't came up with? Is there a way to fix it?