I created a perspective view with nothing but a TextField.
The view has a param called "MyOutParm" that is set as an output param **and is bound to the TextField's text property.
I called the view I've just created Subview, and i created a second view, the MainView that is going to use this subview.
I want to show what seems to be a bug in the way MyOutParam is returned when the subview instances are added dynamically.
So in my MainView I added a FlexRepeater with path set to SubView.
Additionally i added an instance of subview via designer. This is for test completeness and infact it works fine.
Then I added a button for adding an instances to FlexRepeater's instance property, a button for setting instances property (so replacing all the instances at once), and here is where the problems arise.
Then, for showing the problem I put a button and a TextArea; when this button is pressed, the content of FlexRepeater's Instances property is display on the TextArea.
The code of Add Instance:
newInstance = {}
self.getSibling("FlexRepeater").props.instances.append(newInstance)
The code of Replace Instances:
newInstance = {}
newInstances = []
newInstances.append(newInstance)
self.getSibling("FlexRepeater").props.instances = newInstances
The code of DisplayFlexrepeaterInsances:
insts = self.getSibling(FlexRepeater).props.instances
self.getSibling(TextArea).props.text = insts
Pressing Add Instance and then the display button, what I get is:
[{"MyOutParam":"initial text","instancePosition":{},"instanceStyle":{"classes":""}},
{"MyOutParam":"initial text"}]
You see that the second item gets correcly created and even if I didn't add MyOutParam when I created it, the param is correcly added by the component.
Adding instnaces always work.
Now, if i click on 'Replace instances', that sets the whole Instances property, and then I click on the display button, what I get is:
[{}]
That is, MyOutParam is not created by the subview.
I bumped into this because I populate instances from database records by binding the instance property of FlexRepeater to a property that conatins a resultset.
res = []
for i in range(0, value.getRowCount()):
viewParams = {}
viewParams["id"] = value.getValueAt(i, "ID")
res.append(viewParams)
return res
Now I'm considering just clearing the array and adding the new instances, but how to do this when the instance property is set via binding? Seems not possibile, and it may require an other approach, maybe a change script on the origin property.