Is this the same id used in system.perspective.openPopup(id)? Because here it suggests that this id will be unique(assuming we give each popup a unique id that is).
I just tried the following. In an action script on a component in my popup view I ran:
system.perspective.print(self.view.id)
The output is:
Input/Select From List@PSelectFromList
and SelectFromList is the id I passed into system.perspective.openPopup(id). So if I open multiple instances of my popup view and pass it a unique id then each instance of that view will have a unique self.view.id. So the blanket statement that “All instances of a View will have the same ID.” is not really correct, is it?
How would you normally handle a popup closing itself? Open the popup with a unique id, pass the view it’s own id in a parameter, then the view can reference that parameter to close itself?
Because a View can be in use multiple places at the same time. There’s nothing to stop a session from opening multiple Popups which use the same View, FROM a “main” View which is the same View, which has Docked Views which are all the same View. Across multiple tabs. All of those Views would have the same ID if the id was built in as part of the View.
Now, even supposing you’re only talking about a View used in a Popup, I might have opened several of the same Popup but with different parameters. I only want to close the old one which is no longer in use for one reason or another and I want to keep my “new” popup open. If we closed all of the Popups with an id determined by the View, then all of my Popups would close.
All of those Views would have the same ID if the id was built in as part of the View.
If we closed all of the Popups with an id determined by the View, then all of my Popups would close.
True - only if the id on the view was static (which would be pointless and impractical, as you have pointed out)
False - if the view self generated a unique id (or was provided one) each time it is instantiated.
I'm still unclear on:
“All instances of a View will have the same ID.”
This is true, except for popup views which are assigned an id when they are opened and it's up to the opener whether or not the id assigned to the view will be unique?
You seem to be assuming the Popup has some special logic for determining the id. If we generate a unique id for the popup when it is opened, how do we provide that id to the invoking component? How does that id get accessed from within the View which will be used for the Popup.
If we assume that the id property is a param of the View which will be used, well we're stepping on users who design their View with a param of id without knowing that key will be used by some piece of the application. For example: I have a FlexRepeater which pipes a row of a query to each instanced view, but my query is returning columns of id, location, and href. My supplied id param is going to contend with the id injected as part of the Popup Event, so we can't do that.
We could generate a unique id as part of the system.perspective.openPopup() call (and togglePopup as well) and return it so that you get something like this:
But that's useless to the View within the Popup, which is where you really want to place buttons which control the Popup. Also, this would not work for Popup ACTIONS - it would only work for scripts because actions have no way to return values.
OR
Maybe I'm misunderstanding your concerns. If your concern is that the documentation is claiming that all instances of a View will have the same ID, well, the documentation is maybe a little off, because as you mentioned I can see the identifier used to open the Popup as part of the id.
Let me research it a bit more.
After researching this and speaking with the All-Knowing Carl, it seems like the documentation is indeed incorrect. I’ve reached out to have it fixed. The id of a View is constructed form two pieces: the path of the resource, and the mount location within the primary view.
As Popups are not “mounted” to the primary view, we directly append the id used to open the Popup to the path of the instanced View.
In instances where a view IS mounted (for example, in a component form the Embedding category), then you’ll see a path akin to this: Popup@C$0:9[x]. That path is the result of using a Flex Repeater to instance a View named “Popup” where “Popup” resides at Perspective/Views/Popup, and the Flex Repeater is the 9th (zero-indexed) child of the View used for the Primary View.
Thanks for the clarification. It really didn’t make sense for all views of the same type to have the same id. After all, what’s the point of an id if it’s not going to be unique? Each view of the same type already have the same path so it’s a bit redundant for them all to have the same id.
I was expecting similar behavior to the equivalent vision functions. When opening a popup the function returns something the calling block can use in the future to locate/identify/close the window/view. And the view/window would be able to simply close itself. The latter being possible with a popup view since the id supplied in the openPopup function is embedded in the view.id and can be extracted (I’m already doing that. Not sure how reliable it will be though). An auto generated id could be returned by openPopup for use by the calling component to close the view.