Hi Andreas,
> Regarding qooxdoo, your explanations are not quite correct...
Yes, you're right. I did a quick test before posting my answer, but I drawn
wrong conclusion due to a bug in my test script. Sorry, this is my mistake. I
should be more careful next time.
> There are some actions that call dispose() automatically - for
> example, disposing a widget also disposes all of its children.
> However, the removeAll() method of a widget _doesn't_ dispose the
> children, so you have to do it manually (or write a utility method
> that you can use instead of removeAll()).
A new test script has been made to clarify this topic. (Such an example sould
be included in qooxdoo somehow.) This script is not an universal solution,
just an example to dispose the removed widgets after removing them from the
parent. The order of alert boxes clearly shows what happens. (Simple alert
boxes are used for now, no fancy logging or anything else.)
TestWidget.js:
// Test widget with destructor notification
qx.Class.define("custom.TestWidget",
{
extend : qx.ui.form.TextField,
members :
{
dispose : function() {
alert('dispose method called on: '+this.getValue());
this.base(arguments);
}
},
destruct : function() {
alert('destructor called on: '+this.getValue());
}
});
Application.js:
// Test application
qx.Class.define("custom.Application",
{
extend : qx.application.Gui,
members :
{
main : function()
{
this.base(arguments);
// document layout
var vb = new qx.ui.layout.VerticalBoxLayout;
vb.setDimension('auto', 'auto');
vb.setSpacing(8);
vb.setMargin(8);
// remove button
var bn = new qx.ui.form.Button('Remove all widgets from the box below');
bn.addEventListener('click', function(e) {
alert('calling removeAll();');
hb.removeAll();
alert('disposing widgets');
for(var i in children) {
children[i].dispose();
delete children[i];
}
});
vb.add(bn);
// horizontal box to remove widgets from
var hb = new qx.ui.layout.HorizontalBoxLayout;
hb.setDimension('auto', 'auto');
var b=new qx.ui.core.Border;
b.setWidth(1);
b.setStyle('solid');
b.setColor('blue');
hb.setBorder(b);
hb.setSpacing(8);
hb.setMargin(4);
hb.setPadding(4);
vb.add(hb);
// add some widgets to the horizontal box
var children={};
for(var i=1;i<=3;i++) {
var w = new custom.TestWidget;
w.setValue('Widget #'+i);
hb.add(w);
children[i]=w;
}
vb.addToDocument();
}
}
});
Adding a disposeAll() method to the Parent class maybe the universal solution,
but I'm not aware of the long-term consequences of this action. (Such as what
happens with this method if automatic disposal will finally be supported in
qooxdoo?)
Thank you for your quick correction, Viktor
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel