Template Binding

I’m using a Template Canvas.
The Template Canvas has a Custom Property ‘PropX’.
The Template Canvas is dynamically populated with templates using a script.
The Template has a Custom Internal Property ‘PropY’.

I would like to bi-directionally bind ‘PropY’ to ‘PropX’.

The idea is that when I update ‘PropX’ on the Canvas, all the templates are updated, and when I click on one of the templates to update it’s PropY, it also updates all other templates.

I can do this using a Client Tag, but I would like to have the Template Canvas ‘self contained’ so that it can easily be used in multiple locations.

I’ve tried using an indirect tag on the template like this:
‘{1}.parent.parent.parent.parent.PropY’ where {1} = Template.Name
This format works in a script when updating the Canvas from the Template, but not for an Indirect Tag.

Any help appreciated.

Anybody got any ideas on this one?
Do you need more information?

Ok, I’ve managed to do it in a script that I’ll use for now, but it’s a bit messy so if there’s a better way, please let me know.

I’ve added a custom method to the ‘Template Canvas’ that will update all templates within the Canvas called ‘UpdateComponents’.
This is triggered from the canvas properytChange event when the selected property is changed.

def UpdateComponents(self, templateName, propertyName, newValue):
	Update the property of all templates of the same type within the Template Canvas with a new value 
		self: A reference to the component instance this method is invoked on. This argument
		  is automatic and should not be specified when invoking this method.
		templateName: The name of the template within the Template Canvas to update
		propertyName: the property of the template to change
		newValue: the value to set the property to

	# Drill down to where the templates are	
	children = self.getComponents()
	if len(children) > 0:
		for item in children:
			className = str(item.getClass()) 
			if className.endswith("TemplateCanvas$1'>"):
				itemChildren = item.getComponents()
				if len(itemChildren) > 0:
					for temp in itemChildren:
						className = str(temp.getClass()) 
						if className.endswith("JViewport'>"):
							tempChildren = temp.getComponents()
							if len(tempChildren) > 0:
								for temp1 in tempChildren:
									className = str(temp1.getClass()) 
									if className.endswith("LayoutPanel'>"):
										temp1Children = temp1.getComponents()
										if len(temp1Children) > 0:
											# iterate throught all the Templates in the Template Canvas
											for temp2 in temp1Children:
												if temp2.name == templateName:
													# this is the specified template,
													# set the new property value
													temp2.setPropertyValue(propertyName, newValue)