Setting initial perspective page

Dumb question…I can’t figure out where to set the initial page when you first start a perspective session.

When a Perspective session is launched form the Designer, it will ALWAYS launch to /. If you want to configure a different page to launch to from the Designer, it should be configured to use the / path. If you want sessions to launch to a certain page, then you should configure your Session Startup Event to perform the desired navigation to the page of your choice.

From the Docs:

Perspective is designed to operate in a web browsing environment. A Page is the main navigational element in a Perspective Session, so when a Perspective Session starts, it typically begins at the page mounted to the Page URL "/" . The exception to this being cases where the user manually enters a different Page's URL into the address bar of their browser.

1 Like
  1. Click on the “Perspective” root in the project browser
  2. Click on the “/” setting
  3. Select the view that you want to appear as the “/” view

@michael.black in addition to what has been mentioned above, it seems to me that if you have a tab view, the tab that will be shown first when you go to that view is the one which was last open when you saved in the designer. Example: if you have 3 tabs and the middle one is open when you save, that will be the one that is the first thing you see when going to that page.

I may be wrong but that is the behavior I have observed.

Nick

Right…makes sense, forgot about that. What if I am trying to bring in a parameter to the URL? I thought configuring the session startup script would allow me to change the value of the parameter within the URL. If you go to a different page and then go back to that same “home” page the parameter does correctly get populated in the URL.

Here are my project settings with the first one being the “home” page

When I first launch the session the following URL comes up, but the CellId parameter is not populated.

When I navigate back from another page the CellId parameter does populate.

Here is the session script I created in order to populate the CellId on startup

Do I have the formatting incorrect for the session startup script?

The screenshot of the Session Startup script is doing one thing: it is setting a variable named “CellId” to a value of ‘C2’. this variable is scoped ONLY TO THIS SCRIPT. If you want to make use of that value in a session, you have to write it to session.custom.CellId. This makes it a custom property for the session, but even this does not perform the navigation I suggested. If you want the session to navigate to to “C2” page on startup, you must perform the following in that script or - more likely now that i think about it - the Page Startup Event area which is in that same area:

system.perspective.navigate(page='/C2')

Ah, this makes sense. I actually do have a session.custom.CellId which I am using throughout the program to have one program between four identical “cells”. I am still trying to figure out the best way to populate this CellId with different values for the four cells without having to create four projects which are identical with the exception of the CellId being different for each cell.

Well tried that and it did not work. Copy and pasted your line into the session startup script.

Any insight into why it didn’t work? Logged errors? Did you try it in the Page Startup instead? The “session” might not actually be in a state where you can navigate in the Session Startup Event because a session starts before a Page does, but you need to have the page context to navigate. This is why I recommended moving the script location.

I did not get any errors in the logs, it just simply goes to / instead of /C2/.

I do see the page startup script but that looks like it gets executed everytime any page opens within the session. Also I’d like the C2 to be replaced by other values based on which cell you are on.

So you are suggesting I replace all instances of “:CellId” on all pages with this page script?

I placed the script on the page script instead and it did work! I left all page URL’s the same related to including ‘:CellId’ and it still correctly went to /C2/… pages correctly which was surprising, I guess I thought that it would add /C2 in front of every other single URL which would lead to /C2/C2/…

With that working…would I be able to set the session.custom.CellId parameter on the session startup script to match what I want it to be for each cell? Then read in that value for the page setup script and place that within the navigation command in the page setup script?

The Page Startup script opens whenever a new browser tab is opened to a Perspective project, after the page context is set.

In your Page Startup script, you would do something like this:

system.perspective.navigate(page="/" + page.session.custom.CellID + "/")

But note that this is al based off a session custom property which you already have set to "C2". I don't know what your plan is for how to set it based on these other values:

I see, thanks! I am thinking of maybe setting the session.custom.CellId on the startup script based on the IP address of the session, or would that not be possible? Or maybe use the session host id? I am trying to avoid making four identical projects with the only difference being the custom.CellId property to differentiate between the cells

Without understanding the larger layout of the project, I can’t really recommend a route for you. Why do you need four identical projects with only a minor difference? It seems like you could one one project where this “cell” is just the parameter to switch information. How you get that information I don’t know. What you could do is set all of this project up as a “parent” project, then just make four child project which all inherit from the parent, where each child has the “cell” set as the custom property.