Hi everyone,
I write a little piece of code to make easier refreshing multiple tables, but still do not get it work,
is there a way to refresh multiple components?
this is the code i write but i get the error :
TypeError: refresh(): 1st arg can’t be coerced to javax.swing.JComponent
CODE
List = [ “Power Table”,“Power Table 1”]
ListName = [“Component”]*len(List)
for i in range(len(List)):
ListName[i] = “event.source.parent.getComponent(’”+str(List[i])+"’)"
system.db.refresh(str(ListName[i]), “data”)
i don’t think you can use a list for this. If you only have two tables, you could just run two separate refreshes. If you have many, you could create a loop.
table = event.source.parent.getComponent("Power Table")
table1 = event.source.parent.getComponent("Power Table 1")
system.db.refresh(table, "data")
system.db.refresh(table1, "data")
Sure, you can use a list - just gotta treat the things a bit differently.
components = [
"Power Table",
"Power Table 1"
]
for name in components:
component = event.source.parent.getComponent(name)
system.db.refresh(component, "data")
2 Likes
You are right, that is what i was trying to articulate with the loop option.
1 Like