Perspective URL props to docked window

Been having some trouble with something that seems like it really shouldn’t be difficult.

We have a perspective project that utilizes a parameter specified in the URL. For the main views on pages this works as expected. But there doesn’t appear to be an easy way to get that parameter for docked views however. I can try to use the page.props.pagePath, but if the user goes and changes the URL manually, or opens a bookmark, it seems to me there is a bug where it gives the previous page path.

So here’s what I’m doing right now:

  1. Navigate to a page; the main view and docked view start.
  2. On the startup script of my docked window, I send a message to the main view saying “I’m open now and running”.
  3. The Main view on that page receives the message, and then sends a 2nd message saying “this is the parameter from the url”.
  4. then the docked window can now run a script to load things in based on the parameter, now that I know that both views are running/responding. (In this script it tells the main view a bunch of information through another message).

This all assumes that docked views will always start after main views. If it’s random, or just that my main view happens to be finishing first, then potentially this could all break down if the docked view happens to start first (because the main view isn’t fully running yet and won’t receive the message).

We cannot use a session property, because a user might have 3 or 4 pages open at the same time, with different parameters in the url to look at totally different things.

Is there a better way? It’s very weird to me that docked views can’t get the URL parameter in the same manner as main views.

Additionally, if anyone from Inductive reads this, if passing the URL parameter to a docked view is a difficult change, being able to set custom page parameters would also be a great addition.

Fundamentally, you’re right - this shouldn’t be so difficult. Perhaps we should simply set the page URL parameters on all views that have the proper input defined. So for example, if you had the page mounted at /mypage/:paramName and both your primary view and a docked view defined an input named paramName, we could simply set both.

In the meantime, however, there is an easier way than passing messages, which as you surmised, is not really that safe (you can’t rely on one view loading before the other, their loading speed is relative to their complexity and is largely at the whim of the browser)

The “page” props are themselves a writable space. There’s no issue in you using that namespace for your own purposes. For example, you can do this in your main view’s startup event:
self.page.props.paramSharing = {'paramName': self.params.paramName}

And then you can simply bind something in the docked view to page.props.paramSharing.paramName

(there’s nothing special about the name “paramSharing” you can put them in whatever organization you’d prefer)

2 Likes

I did not know that, could definitely be useful.

Oh ok sweet! Befoere this post I tried assigning a variable and value to page props and got an error but I’ll give it another shot with your example. Thanks!