Getting TagPath from Graphic Display Object

Is there a scripting method to get the Tag Path from a elementary graphic display object?

Example Graphic Object component:
Numeric Label: Value attribute is say set to some tag with pathname “myPath\myTag” <–Tag Path

In the event script for this object I would like to access the Tag Path name (string). Is this possible?

pseudo code might ideally be: event.source.displayPath

Hello,

By “elementary graphic display object” are you referring to a component of some sort? If so then your pseudo code is correct if the scripting event is on that same component.

If you’re trying to access this from another component’s scripting event that is on the same container then you’ll need to use something like event.source.parent.propertyName

If my mind-reading skills are working, it sounds like you are after the tag path that is bound to a property? If so, use this:

w = system.gui.getParentWindow(event) pa = w.interactionController.getPropertyAdapter(event.source, 'value') print pa m = pa.class.getDeclaredMethod('getCurrentTagPath', []) m.setAccessible(True) print m.invoke(pa)A couple comments:
[ul][li]Bindings are not properties of the component – they are part of the window.[/li]
[li]The getCurrentTagPath() method is protected, and java will normally not let you call it. So you have to jump through some hoops.[/li][/ul]

Phil,
Could this be used to drill down into a template instance and get the tag path of a control inside the template?
I have dug around a bit, but can’t seem to get it to drill down and get the path.

Not using a repeater or canvas, just a template on a window.

It should work for an event on a component in the template. Drilling down into a template holder to find the component to pass to getPropertyAdapter() may require some introspection. Start here.

Hi, I just want to bring back this topic about drilling down into a template’s component to get tagPath bonded to it.

So, what I understand from previous conversation is that a window has this called Interaction Controller which handles all events from the components inside. However, a template will be treated as one component inside a window so I can’t get properties of all components inside the template.

I was able to get tagPath of the tag bonded to a component inside a window but not in a template.

Is there anyone who completed the code using template holder?

Any help would be appreciated. Thanks in advance!

I’ve written this code, and it works for me:

w = system.gui.getParentWindow(event)
c = event.source.parent.getInstanceName()

# gets the TemplateHolder component
i = w.rootContainer.getComponent(c)

pa = w.interactionController.getPropertyAdapter(i, 'TagLamp')

m = pa.class.getDeclaredMethod('getCurrentTagPath', []) 
m.setAccessible(True) 
print m.invoke(pa)

‘TagLamp’ is the name of the template parameter from which I want to extract the tagname linked to it.