sendMessage to parent view but not page

I have built my own version of the Tab component from scratch, using a FlexRepeater and an EmbeddedView. It works pretty well, the tab buttons are defined on a separate view and when pressed send a message containing their index param. The custom tab component then reads that message and changes the path of the embedded view to a new one from a dataset. All of this was set up so that I could have a dynamic Tab Container that can build itself from a dataset.

When I have two embedded views on a page each pointing to the tab container, I can give them separate datasets and it builds the unique tabs and pages for each embedded view. The problem is that both embedded views respond to messages from each other because the message scope is set to page. But if I set the scope to view, the button won't pass on information to the parent view that instantiates it.

Is there a way to set the scope of a message to the parent of its view? If not, is there another way I can pass information from a view to it's parent view, particularly when it is instantiated in a Flex Repeater?

You can set the Listen Scopes to Session, and create two Message Type to separate embedded view.

Doesn't really work if I want to instantiate the views. I could make it work with an index param on the embedded view and separate messages for a conceivable number of index values, but I'm sure a cleaner solution exists.

Are output params enough? It should be possible to call it in the parent page.

Give the separate target views unique IDs and pass them down into the embedded views. Have the embedded views include this in their message payload so the receiver can filter for their own ID.


That's a great idea, but are you thinking I use the DomID or include an ID as a param for the view? The manual suggests the DomID should only be used for testing.

Give each view canvas its own generic ID as a custom property. Initialize with a UUID if you like. Pass this as a parameter into every subview in the canvas. Then the subview can include it in message payloads that are intended for their parent.

I tried that, and it works in the template view, but when I try it on the main view it's not responsive.

Using breakpoints I figured out my conditional statement was causing the issues.

	intButtonViewID = payload["viewid"]
	intViewID = self.view.params.viewid
	system.perspective.print("View: " + str(intViewID) + " Button: " + str(intButtonViewID))
	if intButtonViewID == intViewID:
		# Code to switch tabs 

This is part of the message handler of the flex repeater in the template, I pass the condition when previewing within the template but not from the view containing the instance of the template. The values are correct though, the output to the cosole reads: View: 3 Button: 3