PDA

View Full Version : Getting rid of views


cmcginnis
05-05-2003, 09:26 AM
I'm creating instances of a class and putting them into a parent view. Once this is done, is it possible to clear out all the children (the instances) out of the parent? The number of instances are based on user entry and right now it is just adding more and more instances to the class, where I need to build it, wipe it out, build it again.

I was looking at the deleteNode() method, but saw the warning that it may cause a memory leak. Is this still an issue? Is there some other way to accomplish this?

Thanks

antun
05-05-2003, 10:57 AM
Hey Chris

Yes the memory leak bug is still present, so you should avoid the deleteNode() method.

What you can do is replicate views based on a dataset:


<view datapath="myDS:/data/replicatedNode"
pooling="true" />


... and turn pooling on. This causes the views to be reused when the data in the dataset changes.

-Antun

cmcginnis
05-05-2003, 12:58 PM
What if the view is being created in a method and not thru the dataset? Here is an example.

<view name="holder"/>

<method name="putThingsInHolder">
// play around and set some data
for(var i=0; i<20; i++) {
var boxName = "box" + i;
var box = new LzView( this.holder,
{name:boxName} );
}
</method>


This is a simplified example, but I think you get my point. The instances are not being created from a dataset so the pooling thing wouldn't help out.

Thanks!

antun
05-05-2003, 01:21 PM
If that's the case, then I think your only option will be to keep creating new views, and turning their visibility off when you're done with them.

Is there a reason you're not using a dataset with datapaths to manage replication?

Since you're giving the dynamically generated views names, it might be worth considering reusing them, by accessing them by their name?

-Antun