Listing all JComponent Client Properties for a component/window

Say I’m adding some client properties (usually functions) to a window:

window = system.nav.openWindow(path)
window.putClientProperty('p1', p1)
window.putClientProperty('p2', p2)

Then I can read these back by name:

window = system.gui.getParentWindow(event)
p1= window.getClientProperty('p1')
p2= window.getClientProperty('p2')

What options do I have to enumerate through the client properties dictionary? I’d like to be able to copy all the client properties from one window to another (where I may not know the property names ahead of time).

I think I can solve this by either 1.) Using a client property containing a list of relevant property names or 2.) Always using a single known client property, but it seems like there should be a way to list the dictionary keys directly.

window.putClientProperty('propertyList', ['p1', 'p2'])
window.putClientProperty('myProperties', {'p1': p1, 'p2', p2})

There’s a private .getClientProperties() you could try to access from reflection. However, the comments on the documentation for .putClientProperty() pretty clearly encourage you to not go wild with these. I always use a static key for any repeatable purpose. I would examine your use-case to make the property names consistent/known.

1 Like

Interesting side note; custom methods are stored in plain text under the client property vision.custom.functions

functions = window.getClientProperty('vision.custom.functions')
print functions
{newMethod: def newMethod(self):
		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.
	# A custom method.

I don’t know why someone would want to programmatically add custom methods, but if you want to the tools are here.