Is the pageID unique?

First time using the message handler to pass an “authenticated” response from a popup to the page.

I could not find in the documentation if the pageId assigned to the page calling the popup is always unique.

The essence of my question is can there be scenario where one user authenticates other users who happen to have the page open in their respective sessions.

I’m assuming no based on testing, but wanted to be sure.

Thank you,

The pageId is an 8 character unique string generated at runtime for running sessions. Within the Designer, the PageId is different because the Designer has no concept of “Page”. So any usage within the Designer will behave differently than in a running session. I believe the PageId in the Designer is actually the name of the View (since that would be unique within the Designer). Why do you need the PageId within the response? I ask because sessions might have multiple pages open at once, and so a user who has authenticated could potentially have multiple PageIds attributed to their session; any logic tied to a single PageId might not cover all pages for a user.

Maybe I’m doing it wrong. From the parent page I send the pageId as a parameter when I open the popup so that the message handler script in the popup can reference back to the parent page.

What would be the best way to get the popup to “talk back” to the page?

Thank you,

But why do you need to refer to the parent page? You could set the scope of the message handler to only "broadcast" at the page scope, and then you can safely expect that only the "parent" page will hear the message. You'd need to make sure the relevant component on the page is also listening at the page scope.

Oh that makes a lot more sense. I thought I had to specify the parent page because the popup had no awareness to who called it.

It's true that the Popup has no way to directly refer to the "parent" page it belongs to. You should only need to specify a pageId argument if you intent to target a different page. For example, consider a session which has two pages open. You place a button which is supposed to close the other page. You would use something like this:

session_objs = system.perspective.getSessionInfo()
for session_obj in session_objs:
    if session_obj.id == self.session.props.id:
        for page_id in session_obj.pageIds:
            if page_id != self.page.props.pageId:
                system.perspective.closePage(pageId=page_id)

Where you actually what page needs to be acted on. If you do not supply the pageId, then the function acts on the current page.

3 Likes

Got it. Thanks for explaining all that.

1 Like